<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z00007Zxf3cCABOkta Classic EngineAPI Access ManagementAnswered2022-06-21T17:29:28.000Z2022-04-13T20:58:46.000Z2022-04-14T23:05:47.000Z

MattM.47662 (Customer) asked a question.

Invalid Token when using oauth on backend server call

Using Python to implement a backend service call to verify a user by login. The token call comes back with a token but the users call always return Invalid Token. Custom authentication 'default' server, etc, is all set up correctly. Note if I generate a token in the API Tokens tab and copy it into my program the users call works fine. What am I doing wrong? Here is the code:

 

  client_domain = os.getenv('SECRET_DOMAIN', None)

  client_id = os.getenv('SECRET_APP_ID', None)

  client_secret = os.getenv('SECRET_APP_SECRET', None)

 

  url = f"https://{client_domain}/oauth2/default/v1/token"

  data = {'grant_type': 'client_credentials',

      'client_id': client_id,

      'client_secret': client_secret}

 

  response = requests.post(url, data=data)

  accesstoken = response.json()["access_token"]

 

login = urllib.parse.quote(incoming.login)

  user_url = f"https://{client_domain}/api/v1/users/{login}"

  bearer = f"SSWS {accesstoken}"

  headers = {"Authorization": bearer,

        "Accept": "application/json", "Content-Type": "application/json"}

 

  response = requests.get(user_url, headers=headers)

 

b'{"errorCode":"E0000011","errorSummary":"Invalid token provided","errorLink":"E0000011","errorId":"oaegW6pmocCSL62-_4yHG3E-Q","errorCauses":[]}'


This question is closed.
Loading
Invalid Token when using oauth on backend server call