Unable to access API endpoint via python request lib, but curl works

Hello,
I am trying to retrieve the JSON Web Key Set from the Okta’s OpenID Connect & OAuth 2.0 API service. When I query the API over curl, it works. However, if I query the same API using python’s request library, I always get a 405 error with the following error message:

{“errorCode”:“E0000022”,“errorSummary”:“The endpoint does not support the provided HTTP method”,“errorLink”:“E0000022”,“errorId”:“oaeioMrcqfTRPmvFO0rWdRQcQ”,“errorCauses”:[]}

Here’s my python code (I am intentionally obfuscating my ids):

import requests
url = “https://dev-XXX.okta.com/oauth2/default/v1/keys&client_id=XXX
resp = requests.get(url)

Here’s my curl request:

curl https://dev-XXX.okta.com/oauth2/default/v1/keys&client_id=XXX

PS. If i copy and paste the same url into my browser, I get the same 405 error I get in python.

Please help!

Welcome to the community.

the client_id parameter is only available for the Okta Org Authorization Server… Our error message lead you astray though. If you drop the client_id, then the call will work.

https://developer.okta.com/docs/reference/api/oidc/#keys

I need a little more coffee - your url needs to change. Use a ? for query parameters

Change:
https://dev-XXX.okta.com/oauth2/default/v1/keys&client_id=XXX
to
https://dev-XXX.okta.com/oauth2/default/v1/keys?client_id=XXX

1 Like

Yes…that was it. Thanks!