Is it possible to get your own username via the API to display your own stream data. I can get a token via client id and secret, but I can’t find an API function that uses the token to get my own username. I would like to display this in my app and not enter it there. Is this possible ?
Call Get Users and omit the ID and login
Gets information about one or more specified Twitch users. Users are identified by optional user IDs and/or login name. If neither a user ID nor a login name is specified, the user is looked up by Bearer token.
So using the example
curl -X GET 'https://api.twitch.tv/helix/users' \
-H 'Authorization: Bearer cfabdegwdoklmawdzdo98xt2fo512y' \
-H 'Client-Id: uo6dggojyb8d6soh92zknwmi5ej1q2'
Will return the user whom belongs to that oAuth token. (Example from the documentation)
That’s what I thought, but id without user_id get this error message
GET ‘https://api.twitch.tv/helix/users’
–header ‘client-id: vxaqrypwcwtxvv97k1sootuby3XXXX’
–header ‘Authorization: Bearer REMOVED’
{“error”:“Bad Request”,“status”:400,“message”:“Must provide an ID, Login or OAuth Token.”}
ADMIN: DO NOT POST YOUR TOKEN PUBLICALLY EVEN PARTIALLY!!!
Is the OAuth token you’re using a User Token? If it’s an App Access Token from the Client Credentails flow then there’s no user associated with it since it’s an app token, and so wouldn’t be able to return the user of that token.
As Dist says, it’s either a token of the wrong type. (It has no user Attached)
or the token has expired, since a (regular) user token is only valid for four hours. Then you have to refresh it (if you can) or get a new user token.
This JS example will demonstrate using an implicit user token
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.