Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OAuth 2 Authorization Code - how long is it valid?

In Webserver Grant Flow After I obtain the Authorization Code from the authorization authority (after the user has authorized my access) how long is that code usually valid form? The reason i am asking is, can my webserver store that code and use it in later sessions to retrieve a new access token without the need for the user to re-authenticate again? Should that be the flow?

FYI my goal is make requests from Adobe Analytics and Google Analytics on behalf of my customer. So i would want to ask my customer for authorization once until he revokes my access.

like image 863
Berethor Avatar asked Feb 20 '17 13:02

Berethor


People also ask

What can I do with the OAuth authorization code?

The only thing you can do with the authorization code is to make a request to get an access token. Up until 2019, the OAuth 2.0 spec only recommended using the PKCE extension for mobile and JavaScript apps. The latest OAuth Security BCP now recommends using PKCE also for server-side apps, as it provides some additional benefits there as well.

What is OAuth 2 0 token?

Refresh the access token The OAuth 2.0 authorization code grant can be used in apps that are installed on a device to gain access to protected resources, such as web APIs. Using the Microsoft identity platform implementation of OAuth 2.0, you can add sign in and API access to your mobile and desktop apps.

How long does an OAuth token last?

The OAuth 2.0 spec recommends this option, and several of the larger implementations have gone with this approach. Typically services using this method will issue access tokens that last anywhere from several hours to a couple weeks.

What is the OAuth2 code flow?

The OAuth 2.0 authorization code flow is described in section 4.1 of the OAuth 2.0 specification. It's used to perform authentication and authorization in the majority of app types, including single page apps, web apps, and natively installed apps. The flow enables apps to securely acquire access_tokens that can be used to access resources ...


1 Answers

Speaking strictly of Google Oauth. There are three types of codes or tokens you should be aware of.

  1. Authorization code
  2. Access token
  3. Refresh token

Authorization code is return when the user clicks accept to your application accessing their data. This code is used to exchange for an access token and a refresh token. This code can only be used once and is extremely short lived 10 minutes I believe.

Access tokens are used to access private user data. They are valid for approximately one hour.

Refresh tokens are used to gain a new access token when the access token has expired. For the most part refresh tokens do not expire however if it has not been used for six months it will no longer be valid and of course the user can always remove your access.

Answer: No storing the authentication code would be pointless. You will need to store the refresh token. make sure you are requesting offline access of your users.

I cant help you with adobe analytics however I suspect it is similar this is standard Oauth protocol we are talking about.

like image 169
DaImTo Avatar answered Oct 12 '22 00:10

DaImTo