# How can I generate access token and refresh token together on a login of user..?

**URL:** <https://community.auth0.com/t/how-can-i-generate-access-token-and-refresh-token-together-on-a-login-of-user/44325>\
**Category:** JWT.io\
**Created:** [June 8, 2020, 9:15pm UTC](https://community.auth0.com/t/how-can-i-generate-access-token-and-refresh-token-together-on-a-login-of-user/44325 "2020-06-08T21:15:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![John.ICM](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@John.ICM](https://community.auth0.com/u/John.ICM)\
**Post date:** [June 8, 2020, 9:15pm UTC](https://community.auth0.com/t/how-can-i-generate-access-token-and-refresh-token-together-on-a-login-of-user/44325/1 "2020-06-08T21:15:36Z")

</div>

I am using Laravel framework with tymon JWT library trying to generate access token and refresh token together for a user login, kindly suggest the way to do it.  
thanks.

---

<div class="post-metadata">

**Author:** ![markd](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/markd/32/38919_2.png) [@markd](https://community.auth0.com/u/markd)\
**Post date:** [June 8, 2020, 11:13pm UTC](https://community.auth0.com/t/how-can-i-generate-access-token-and-refresh-token-together-on-a-login-of-user/44325/2 "2020-06-08T23:13:23Z")

</div>

Hello @John.ICM,

Welcome to the Community! I’m not familiar with Laravel specifically, but you can get a refresh token along with your access token by including the `offline_access` scope when you callthe `/authorize` endpoint. E.g.,:

```auto
https://YOUR_DOMAIN/authorize?
    audience={API_AUDIENCE}&
    scope=offline_access&
    response_type=code&
    client_id=YOUR_CLIENT_ID&
    redirect_uri=https://YOUR_APP/callback&
    state={OPAQUE_VALUE}

```

> **[Get Refresh Tokens](https://auth0.com/docs/secure/tokens/refresh-tokens/get-refresh-tokens)**
>
> Describes how to get a Refresh Token when you initiate a request using the Authorize endpoint.

---

<div class="post-metadata">

**Author:** ![John.ICM](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@John.ICM](https://community.auth0.com/u/John.ICM)\
**Post date:** [June 9, 2020, 12:10am UTC](https://community.auth0.com/t/how-can-i-generate-access-token-and-refresh-token-together-on-a-login-of-user/44325/3 "2020-06-09T00:10:48Z")

</div>

Hello mark  
Thanks for your reply.  
I do not understand what actually you mean by including the `offline_access` scope.

is the user must have a valid token for applying it…?  
i want to generate the access token and refresh token both on the same time i.e when user enters correct credentials.

Also mark kindly clarify that your solution will only work if i am using Auth0 application on my project.  
Or it will work with any JWT library which do not use Auth0…?
