Class: Strava::Models::Token

Inherits:
Response show all
Defined in:
lib/strava/models/token.rb

Overview

Represents an OAuth token response from Strava.

This model is returned when exchanging an authorization code for an access token or when refreshing an expired token. It contains the access token, refresh token, expiration time, and basic athlete information.

Tokens expire after a period of time (typically 6 hours). When a token expires, use the refresh_token to obtain a new access_token via the OAuth flow.

Examples:

Inspecting token information

token = client.oauth_token(code: 'auth_code')
puts "Access Token: #{token.access_token}"
puts "Refresh Token: #{token.refresh_token}"
puts "Expires at: #{token.expires_at}"
puts "Athlete: #{token.athlete.firstname} #{token.athlete.lastname}"

See Also:

Instance Method Summary collapse

Instance Method Details

#access_tokenString

Returns OAuth access token for API authentication.

Returns:

  • (String)

    OAuth access token for API authentication



30
# File 'lib/strava/models/token.rb', line 30

property 'access_token'

#athleteStrava::Models::SummaryAthlete

Returns Summary of the authenticated athlete.

Returns:



42
# File 'lib/strava/models/token.rb', line 42

property 'athlete', transform_with: ->(v) { Strava::Models::SummaryAthlete.new(v) }

#expires_atTime

Returns Expiration time of the access token.

Returns:

  • (Time)

    Expiration time of the access token



39
# File 'lib/strava/models/token.rb', line 39

property 'expires_at', transform_with: ->(v) { Time.at(v) }

#expires_inInteger

Returns Number of seconds until token expires.

Returns:

  • (Integer)

    Number of seconds until token expires



36
# File 'lib/strava/models/token.rb', line 36

property 'expires_in'

#refresh_tokenString

Returns Refresh token for obtaining new access tokens.

Returns:

  • (String)

    Refresh token for obtaining new access tokens



33
# File 'lib/strava/models/token.rb', line 33

property 'refresh_token'

#token_typeString

Returns Type of token, typically "Bearer".

Returns:

  • (String)

    Type of token, typically "Bearer"



27
# File 'lib/strava/models/token.rb', line 27

property 'token_type'