I want to create mini-games on my website and saving scores of the players with their Twitch username, I want the players to use their Twitch account to play,
I succeeded to use this Get Users Api Twitch and I can now see my own informations on my website but I had to hard-code my username as the login Optional Query Parameter,
How can I after redirecting the user to this link (link Twitch), get his username to put it instead of my hardcoded username ?
Oh thanks, I was now looking at the “Validation requests” section of this page Authentication | Twitch Developers, it looks like it returns the username too ?
I want that the user datas to persist in my website to avoid the user to have to authorize the app via Twitch Popup everytime, I can use localStorage to store the accessToken and the expirationDate ?
How do you do to avoid the user to click on “authorize app” ? It looks like the redirection is done automatically on your site ?
You normally wouldn’t use client side, You’d use a server based session for this, but depends on the use case, And thus not use implict auth.
However, sure you can store the users own token in the users own localStorage.
This depends how you want to manage user website persistance. For my websites/minisites, I’ll use regular oAuth flows to get a server session and back that with my DB. but depends what I need to login people for.
The linked Implict Auth Example, is just an easy way to demonstrate how to get a user from a oAuth token.
You have to click “authorize app” to provide a token.
Without force_verify if you already linked, the flow just loops around without the “confirm” link. If thats what you mean.
This question is unclear
This example being implict auth.
The user clicks the auth link. - https://id.twitch.tv/oauth2/authorize?client_id=hozgh446gdilj5knsrsxxz8tahr3koz&redirect_uri=https%3A%2F%2Fbarrycarlyon.github.io%2Ftwitch_misc%2Fauthentication%2Fimplicit_auth%2F&response_type=token
That goes to twitch
They accept/decline (skipped if authed once and no forceverify)
They return to the webpage with a https://barrycarlyon.github.io/twitch_misc/authentication/implicit_auth/#access_token=TOKENHERE
My code grabs the #access_token from the URL
And then uses the access token in the calls to helix.
For implcit auth there is no ?code to access token exchange
As the access token is provided in the URL fragment