Closed The1337DudeSD closed 4 months ago
The code example I'm using is working fine.
So, are you sure you are passing the correct device_code
and correct grant_type
into the request similar to
fetch(
`https://id.twitch.tv/oauth2/token`,
{
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: new URLSearchParams([
[ 'client_id', process.env.CLIENT_ID ],
[ 'device_code', device_code ],
[ 'grant_type', 'urn:ietf:params:oauth:grant-type:device_code' ]
])
}
)
As you might have got the request wrong as per #952 due to a documentation error, (my code example was built off the device code RFC rather than the documentation)
Hey @BarryCarlyon,
Thanks for replying back, you're right turns out that I was using the user_code
for the second API and the API was returning the right error response as expected, it started sending the right error response once I passed the right code(device_code
). Sorry about the confusion.
Cheers
Brief description
Hello Twitch Team,
I'm trying to implement the Device Code Grant Flow, I'm able to retrieve the device code via the
https://id.twitch.tv/oauth2/device
API but when I try to poll thehttps://id.twitch.tv/oauth2/token
API with the device code, while the user is authorizing app using the device code, I get an error response saying "invalid device code" instead of "authorization_pending"(as mentioned in the docs here:https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#device-code-grant-flow
).However, the user is still able to authorize the same device code and complete login process.Could you please help.
How to reproduce
https://id.twitch.tv/oauth2/device
API with an App'sclient_id
and appropriate scopeshttps://id.twitch.tv/oauth2/token
with the retrieved device code.Expected behavior API would respond with "authorization_pending" as mentioned in the docs
Screenshots N/A
Additional context or questions N/A