Refresh a Token

Last updated: September 03, 2020

Introduction

A Refresh Token is a special kind of token that contains the information required to obtain a new Access Token or ID Token.
Usually, a user will need a new Access Token only after the previous one expires, or when gaining access to a new resource for the first time.

Refresh Tokens are subject to strict storage requirements to ensure that they are not leaked.

How to implement ?

Get a refresh Token


To get a Refresh Token, you must use the Authorization Code Flow

In response you will get a JSON object containing the following fields:

  • access_token: The access token for the user. This value must be secured.
  • token_typeThe type of token this is, typically just the string “bearer”.
  • expires_inThe number of seconds remaining, from the time it was requested, before the token will expire.
  • refresh_token: (optional) can be used to obtain another access token after access_token expiration.
  • jti: (optional) The "jti" (JWT ID) claim provides a unique identifier for the JWT.



Refresh Your Token


To refresh your token, using the Refresh Token you already got during authorization.


POST /connect/oauth/token

Headers :
Parameter Description Required
Authorization Basic encodedString (where encodedString is the result of base 64 encoding the OAuth client's values as clientId:clientSecret Yes


Body (x-www-form-urlencoded) :
Parameter Description Required
grant_type The value of this field should always be: refresh_token Yes
refresh_token The refresh token issued to the client. Yes
scope The scope of the access request.The requested scope MUST NOT include any scope not originally granted by the resource owner, and if omitted is treated as equal to the scope originally granted by the resource owner. OPTIONAL

For example, a successful call :


curl --location --request POST 'https://api-global.preprod.decathlon.net/connect-re7/oauth/token' \
--header 'Authorization: Basic Y2xpZW50LWRlZmF1bHQ6Y2xpZW50LWRlZmF1bHQtc2VjcmV0' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'refresh_token={{refresh_token}}' \
--data-urlencode 'grant_type=refresh_token'


                                                

In response you will get a JSON object containing the following fields:

  • access_token: The NEW access token for the user. This value must be secured.
  • token_typeThe type of token this is, typically just the string “bearer”.
  • expires_inThe number of seconds remaining, from the time it was requested, before the token will expire.
  • refresh_token: A NEW refresh Token.
  • jti: (optional) The "jti" (JWT ID) claim provides a unique identifier for the JWT.

For example, a successful token response may look like the following:


{
    "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1YWIxMjY3OC1hY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RrY29ubmVjdCJ9.5f9tqB1G6qZRpGcVwMQlNeqX4Ehi4TFmvVNGofFJpFh-AW5lt-7ye7aKGzYqFdcusDzuuaEDnBnS44qIKUTxomclj1T9BGBYDI5-2PFDFnOaN--ly6dx4vu_TIw9pXJycVCzeq22H5EDrgcF0hbTE4wDQ9lTpV4tDAyYJ3l4QSah9wnWnJQ-Y5rh2v5znQ0Eutu36-tSC_2seII5la_HGrrFuUKNVIu5AJrh_dvs_9Vq-PGu9ODu74bVa8UfMDOEr8sk-ZVvfhiJzzsWBbf7f2wiNneWtA-EhngEA4ZI7RyOeCC_DaGZm6OxW91YyZY-SreFgA",
    "expires_in": 899,
    "scope": "profile",
    "jti": "8198119e-d8b9-475d-819f-a1a42ad9c3d0"
}

                                                
Terms & Services