{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
1
Question by J M · Dec 16, 2016 at 01:14 PM · 206 Views erroroauthtutorialclient identifier

OAuth tutorial: Secure an API with Oauth does not work for me

Hi everyone,

I'm totally noob in the use of apigee, and I'm trying to do the tutorials, but in the mentioned one I'm having the following error:

{"ErrorCode" : "invalid_client", "Error" :"Client identifier is required"}

when trying to make the following cURL call:

C:\Users\essanchezpa1>curl -X POST -H "Content-Type: application/x-www-form-urlencoded" https://fujitsu01-test.apigee.net/oauth/clie nt_credential/accesstoken?grant_type=client_credentials -d 'client_id%3DZeOgdVfmEhwOR9l7t2usqZJVWsb3A04w%26client_secret%3D7w8Lmx8gU hAS46qU'

I have urlencoded the data because if I try this call:

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" https://fujitsu01-test.apigee.net/oauth/client_credential/accesstoken?grant_type=client_credentials -d 'client_id=ZeOgdVfmEhwOR9l7t2usqZJVWsb3A04w&client_secret=7w8Lmx8gUhAS46qU'


Then, I get an additional error saying that "client_secret" is not recognized as an internal or external command, program or batch file. Seems like Windows thinks this is an incorrect command.

Please, can someone help me? I would appreciate some help, in order to understand what's going on.

Thanks in advance.

Comment
Add comment
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Close

1 Answer

  • Sort: 
avatar image
0
Best Answer

Answer by Dino   · Dec 17, 2016 at 01:05 AM

I think the error like "client_secret" is not recognized as an internal or external command,

comes from the Windows cmd.exe executable. cmd.exe interprets the ampersand (&) as a special character that says "everything that follows this is another command". In your case that would be the string starting with "client_secret". You don't want that. The good news is you can quote ampersands (&) in commands to tell Windows "this is just an ampersand". To quote the ampersand in the cmd.exe shell, you can escape it with a caret (^). It looks like this:

curl -i -X POST -H "Content-Type: application/x-www-form-urlencoded" https://fujitsu01-test.apigee.net/oauth/client_credential/accesstoken?grant_type=client_credentials -d client_id=ZeOgdVfmEhwOR9l7t2usqZJVWsb3A04w^&client_secret=7w8Lmx8gUhAS46qU

This is a cmd.exe thing. Has nothing to do with curl. Or Apigee.

Alternatively you can quote the entire -d payload in double quotes rather than single quotes. This again is a technique particular to cmd.exe (and Windows).

Example:

curl -i -X POST -H "Content-Type: application/x-www-form-urlencoded" https://fujitsu01-test.apigee.net/oauth/client_credential/accesstoken?grant_type=client_credentials -d "client_id=ZeOgdVfmEhwOR9l7t2usqZJVWsb3A04w&client_secret=7w8Lmx8gUhAS46qU"

I just tested these commands and they both worked for me from my Windows machine.

You should use one technique (double quotes or caret) or the other; not both together.

Comment
Add comment Show 1 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image J M · Dec 20, 2016 at 07:24 AM 0
Link

Hi @Dino,

Thank you very much. I tried with simple quotes because I thought it was the same effect as double quotes, but it seems it is not.

Kindly regards.

Follow this Question

Answers Answers and Comments

53 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Sample XML Deploy failed with status 400 2 Answers

zookeeper errors during oauth 2.0 performance testing 1 Answer

GetOAuthV2Info for refresh token not getting custom attributes 1 Answer

Use of variable in HTTPTargetConnection.URL 3 Answers

Error fetching permissions for businessuser 0 Answers

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges