[SOLVED] Display_name retrieval with New API + Opaque IDs

While attempting to pass an opaque user ID to get the display_name of a user, I’m running into a bad request with no clear reasons why. Searched all threads but not finding anything with a clear working example other than non-opaque, only a solution from Kraken using v5. Has anyone successfully retrieved a display name via opaque ID on the new API? It works flawlessly on v5 API that is being deprecated in December so I’d like to find a way to update.

For clarity, this is for a Twitch Extension, so my Bearer token is generated by the Twitch onAuthorized callback so it’s not used with the API request.

Request Example of New API:

{
  "method": "GET",
  "url": "https://api.twitch.tv/helix/users?id=<opaque id here>",
  "headers": {
    "Client-ID": "<client_id>"
  }
}

Error Response:

{
  "error": "Bad Request",
  "status": 400,
  "message": "Invalid login names, emails or IDs in request"
}

Works on V5 via the following:

{
  "method": "GET",
  "url": "https://api.twitch.tv/kraken/user?id=<opaque id here>",
  "headers": {
    "Client-ID": "<client_id>",
    "Accept": "application/vnd.twitchtv.v5+json"
  }
}

Responds with user object.

Hey darkvipr, so you are creating a bearer token, but it’s not being used for the API call? Just want to make sure I understand correctly. Auth is required for the /helix endpoints unlike v5 which only requiring the Client ID, so you’ll need to use an auth token, otherwise it’ll return a 400.

Got it. This is for a video overlay and so it’s against the rules to request oAuth permissions for a user. Any thoughts on how we can retrieve a display_name for an extension without requiring oAuth? Guess this could/should be asked in #extensions.

Update: Tracing this further, it seems that the opaque ID isn’t intended to be used for looking up profile data which is why I keep running into a wall and that once the user grants identity link a numerical ID is returned to the onAuthorized callback (which doesn’t appear to be the case yet, still troubleshooting.) I can get a display_name with the numerical ID no problem, so just need to figure out why I can’t get that yet after granting identity link with a test account.

Update 2: 6 hours later of troubleshooting. Opaque ID is used for tracking a user session. Once a user grants identity link the numerical user_id is sent from onAuthorized callback as part of the “token” which you can send to the EBS to decode. After, send a query to Helix API with auth bearer token and client ID to get the user data, then return display_name.

1 Like

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