Hi, i followed this tutorial:
http://docs.apigee.com/tutorials/secure-calls-your-api-through-oauth-20-client-credentials
But when i execute the curl command:
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \ https://{org-name}-test.apigee.net/oauth/client_credential/accesstoken?grant_type=client_credentials \-d 'client_id={consumer-key}&client_secret={consumer-secret}'
Changing the org-name to my org-name, the consumer-key and consumer-secret to that i got from the app i created.
I receive this error:
{"fault":{"faultstring":"Unable to identify proxy for host: secure and url: \/oauth\/client_credential\/accesstoken","detail":{"errorcode":"messaging.adaptors.http.flow.ApplicationNotFound"}}}
Does anyone has any idea why?
Solved! Go to Solution.
HI @Stayfilm
From the screenshot, I see the basepath of your proxy is /hellooauth2
So your curl call should be
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \ https://stayfilmapis-test.apigee.net/hellooauth2/client_credential/accesstoken?grant_type=client_cre... \-d 'client_id={consumer-key}&client_secret={consumer-secret}'
If it still doesn't work, can you share your proxy bundle here ?
To download the proxy, in the Proxy Overview page, click Project --> Download
Hi @Stayfilm Looks like your OAuth proxy is either not deployed to the environment OR not configured to listen on "secure" virtualhost in the default target endpoint.
Hi @Mudit, deployed to the environment i think it is, look:
Now if it is configured to listen on "secure" i don't know.
How do i do to see that?
Thanks!
HI @Stayfilm
From the screenshot, I see the basepath of your proxy is /hellooauth2
So your curl call should be
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \ https://stayfilmapis-test.apigee.net/hellooauth2/client_credential/accesstoken?grant_type=client_cre... \-d 'client_id={consumer-key}&client_secret={consumer-secret}'
If it still doesn't work, can you share your proxy bundle here ?
To download the proxy, in the Proxy Overview page, click Project --> Download
Hi @Stayfilm, Sai got it at first 🙂 he is right on.
I tried that but give me another error:
$ curl -X POST -H "Content-Type: application/x-www-form-urlencoded" \ > https://stayfilmapis-test.apigee.net/hellooauth2/client_credential/accesstoken?grant_type=client_cre... \ > -d 'client_id=mL7lG5PnwNVaRVuQblNnmHeT588l6hdT&client_secret=qOmB1RaUUNjLbiol'
{"fault":{"faultstring":"Invalid access token","detail":{"errorcode":"oauth.v2.InvalidAccessToken"}}}
$
The proxy and app are for test for now, so no problem in post here the consumer key and the secret.
Thanks!
Sorry, i forgot the proxy bundle.
I tried to edit the previous answer but there is some problem on edit that.
Here is the proxy: helloworld-oauth2-rev1-2017-05-19.zip
Hi @Stayfilm - Thanks for sharing the bundle
The one you are using is not an OAuth proxy. Its a pass through API that uses a token that is generated of an OAuth proxy. Please check if you have an "oauth" proxy in your Edge org. If you do, please use the same curl above (check the basepath of that proxy) and generate the token.
Once you have the token, pass that token with Authorization header to this proxy. This proxy has a policy in its Preflow that verifies the access token being passed. A sample curl for your proxy you shared is
curl -X GET \ http://stayfilmapis-test.apigee.net/hellooauth2 \ -H 'authorization: Bearer {{token}}'
For more info on OAuth - please refer this link. Also check this link
This one is a oauth proxy, right?
Bundle here:
When i make the call it gives me the same error:
$ curl -X POST -H "Content-Type: application/x-www-form-urlencoded" https://stayfilmapis-test.apigee.net/oauth/client_credential/accesstoken?grant_type=client_credentia... -d 'client_id=mL7lG5PnwNVaRVuQblNnmHeT588l6hdT&client_secret=qOmB1RaUUNjLbiol'
{"fault":{"faultstring":"Unable to identify proxy for host: secure and url: \/oauth\/client_credential\/accesstoken","detail":{"errorcode":"messaging.adaptors.http.flow.ApplicationNotFound"}}}
$
Oh, now i got it! It was not deployed.
Thanks! 🙂
Cool.. Yes
Now using the token you generated using this OAuth proxy, pass it to the other proxy
curl -X GET \ http://stayfilmapis-test.apigee.net/hellooauth2 \ -H 'authorization: Bearer ******'
You should see a response something like this
{"ip":"73.202.116.214, 104.154.179.1"}
NOTE: Please do not share client credentials in the community, mask them. I would recommend regenerating the developer app so that you get a new set of client credentials. Hope this resolves your issues.
Please accept this answer if it did.
HI @Stayfilm - Can you please accept this answer if this resolved your issue ?