Get access tokken with login in credentials?


#1

Hi, can i ge the access token with the log in credential passed by php script? i cant find anythying on the offical api guide.
for example

POST https://id.twitch.tv/oauth2/token
    ?usernamme=<your client user>
    &passwordt=<your client pass>

or somiliar and get a access tokken?
and the access token can never expire??


#2

Short answer no. The token is retrieved based on Twitch receiving the request from your application with your Client ID and Client Secret. This is essentially how OAUTH works - one important piece is never passing the password/account information for the person that you which to receive a token for.

The tokens do expire, based on their documentation. You will need to look at storing the refresh token and taking the appropriate action or requiring re-authentication as needed.


#3

so even though i have a password and userbname of account, i still need tto let the permission by loggin it (manually) and then get the access token that expire ?

i have this code for get the token

$ch = curl_init("https://id.twitch.tv/oauth2/authorize?client_id=ea5edl3aletwqktirdeva92z47ge4m&redirect_uri=http://localhost&response_type=code";
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
print_r(curl_exec($ch));
curl_close($ch);

but is not prin ting it


#4

That will not print a token. The OAUTH2 flow (which is demonstrated on Twitch’s site) requires you to request the authorization which opens a web browser window, owned by Twitch, which authenticates the user, and then that page redirects the user back to the authentication page that you defined when you defined your application which then has to either retrieve the data from the body of the JSON message or from the URL (depending upon what type of token you request).


#5

okey i added
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
but still without nothing, i will search the curl doc, ty anyway!