Fixed: Problems with OAuth

I use python and using this script:

client_id = 'Hello' # I am using here my real id and client secret as mentioned in the tutorial
client_secret = 'World'

client = BackendApplicationClient(client_id=client_id)
oauth = OAuth2Session(client=client)

token = oauth.fetch_token(
    token_url='https://identity.dataspace.copernicus.eu/auth/realms/CDSE/protocol/openid-connect/token',
    client_id=client_id,
    client_secret=client_secret
)
resp = oauth.get("https://services.sentinel-hub.com/oauth/tokeninfo")
print(resp.content)

def sentinelhub_compliance_hook(response):
    response.raise_for_status()
    return response

oauth.register_compliance_hook("access_token_response", sentinelhub_compliance_hook)

And I still got this error:
oauthlib.oauth2.rfc6749.errors.InvalidClientError: (invalid_client) Invalid client or Invalid client credentials

I checked multiple times that I for sure have the correct id and secret and even recreated it, but still this error.

I am using this version:
oauthlib==3.2.2
requests-oauthlib==1.3.1

Found the error: Wrong link for token fetching.

1 Like

Hello,
I’m having the same issue… What was the correct link for token fetching?
Thanks,
Pauline

Hi @pauline.millet ,

For the Copernicus endpoint the token url is: https://identity.dataspace.copernicus.eu/auth/realms/CDSE/protocol/openid-connect/token.

For detailed configuration please refer to my colleague’s answer here and the Copernicus Data Space Ecosystem documentation.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.