# Get access tokken with login in credentials?

**URL:** <https://staging-discuss.dev.twitch.com/t/get-access-tokken-with-login-in-credentials/18914>\
**Category:** API\
**Created:** [December 3, 2018, 8:49pm UTC](https://staging-discuss.dev.twitch.com/t/get-access-tokken-with-login-in-credentials/18914 "2018-12-03T20:49:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patricio\_Martin](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@Patricio\_Martin](https://staging-discuss.dev.twitch.com/u/Patricio_Martin)\
**Post date:** [December 3, 2018, 8:49pm UTC](https://staging-discuss.dev.twitch.com/t/get-access-tokken-with-login-in-credentials/18914/1 "2018-12-03T20:49:51Z")

</div>

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

```auto
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??

---

<div class="post-metadata">

**Author:** ![IllusionaryOne](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/illusionaryone/32/2011_2.png) [@IllusionaryOne](https://staging-discuss.dev.twitch.com/u/IllusionaryOne)\
**Post date:** [December 3, 2018, 10:54pm UTC](https://staging-discuss.dev.twitch.com/t/get-access-tokken-with-login-in-credentials/18914/2 "2018-12-03T22:54:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Patricio\_Martin](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@Patricio\_Martin](https://staging-discuss.dev.twitch.com/u/Patricio_Martin)\
**Post date:** [December 3, 2018, 11:02pm UTC](https://staging-discuss.dev.twitch.com/t/get-access-tokken-with-login-in-credentials/18914/3 "2018-12-03T23:02:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![IllusionaryOne](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/illusionaryone/32/2011_2.png) [@IllusionaryOne](https://staging-discuss.dev.twitch.com/u/IllusionaryOne)\
**Post date:** [December 3, 2018, 11:07pm UTC](https://staging-discuss.dev.twitch.com/t/get-access-tokken-with-login-in-credentials/18914/4 "2018-12-03T23:07:32Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Patricio\_Martin](https://avatars.discourse-cdn.com/v4/letter/p/b5e925/32.png) [@Patricio\_Martin](https://staging-discuss.dev.twitch.com/u/Patricio_Martin)\
**Post date:** [December 3, 2018, 11:09pm UTC](https://staging-discuss.dev.twitch.com/t/get-access-tokken-with-login-in-credentials/18914/5 "2018-12-03T23:09:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://d2spem0quai2ol.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://staging-discuss.dev.twitch.com/u/system)\
**Post date:** [January 2, 2019, 11:09pm UTC](https://staging-discuss.dev.twitch.com/t/get-access-tokken-with-login-in-credentials/18914/6 "2019-01-02T23:09:07Z")

</div>

Closed on January 2, 2019, 11:09pm UTC

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