stravalib.client.Client.exchange_code_for_token#

Client.exchange_code_for_token(client_id: int, client_secret: str, code: str, return_athlete: bool = False) AccessInfo | Tuple[AccessInfo, SummaryAthlete | None][source]#

Exchange the temporary authorization code (returned with redirect from Strava authorization URL) for a short-lived access token and a refresh token (used to obtain the next access token later on).

Parameters:
  • client_id (int) – The numeric developer client id.

  • client_secret (str) – The developer client secret

  • code (str) – The temporary authorization code

  • return_athlete (bool (default = False)) – Whether to return a SummaryAthlete object (or not) This parameter is currently undocumented and could change at any time.

Returns:

  • AccessInfo – TypedDictionary containing the access_token, refresh_token and expires_at (number of seconds since Epoch when the provided access token will expire)

  • tuple

    Contains:
    • the AccessInfo typed dict containing token values

    • a SummaryAthlete object representing the authenticated user.

Notes

Strava by default returns SummaryAthlete information during this exchange. However this return is currently undocumented and could change at any time.