Search code examples
oauth-2.0apigee

Not Able to generate OAuth 2.0 Access Token in APIGee


I am new to APIGee. In my project i am using OAuth 2.0 for Authentication.But i am not able to generate the Access Token. I have created all required policies, but still i am getting the same error all the time.

This is the command i am using to generate the Access Token.

I am using Postman to generate the Access Token.

https://<myorgname>test.apigee.net/<myproxyname>/client_credential/accesstoken?grant_type=client_credentials&client_id=<myclient_id>&client_secret=<myclient_secret>’

I have also tried with curl

https://<myorgname>test.apigee.net/<myproxyname>/client_credential/accesstoken?grant_type=client_credentials -X POST -d 'client_id=<myclient_id>&client_secret=<myclient_secret>’

Both of them give the same error

{ "fault": { "faultstring": "Classification failed for host orgname-test.apigee.net", "detail": { "code": "CLASSIFICATION_FAILED" } } }

Please help. Thanks in advance.


Solution

  • "Classification failed" generally means that the URL is not resolving to any endpoint. There can be several reasons for this:

    1. You are sending in the wrong URL. The URL you need to send in is hostname + basepath + pathsuffix. When you create a proxy in Apigee, by default your basepath will look something like /v1/proxyname. Make sure the /v1 isn't missing. You can also use trace to see what the hostname + basepath is supposed to be.
    2. You are calling https, but your proxy isn't set up for it. Make sure the secure virtual host is referenced in your ProxyEndpoint.
    3. Your HTTP verb may be incorrect. Usually you need to use a POST to get an OAuth token. Make sure your verb matches your implementation. If you don't provide a verb using CURL, it defaults to GET.
    4. Probably not the cause of your error, but the OAuth parameters are generally sent in via a x-www-form-urlencoded payload, not via the command line. Also, the client ID and secret are generally passed in via Basic Auth. Apigee expects these locations by default. See the OAuth 2.0 spec and Apigee's docs for details.