The access token returned by the intervals.icu token endpoint.
intervals.icu returns a deliberately small token payload:
{
"token_type": "Bearer",
"access_token": "d842c1fc25f241e5ae440d09756448a9",
"scope": "ACTIVITY:WRITE,WELLNESS:WRITE",
"athlete": { "id": "2049151", "name": "David (intervals.icu)" }
}Two things are worth calling out, because they differ from most OAuth 2.0 providers:
There is no
refresh_tokenand noexpires_in. Tokens do not expire on a timer. SeeUeberauth.Strategy.IntervalsIcufor what that means for your application.The athlete's id and name are included in the token response itself, so a separate user-info request is optional rather than required.
Any field intervals.icu adds in the future is preserved in :other_params
rather than being discarded.
Summary
Functions
Builds a token from a decoded token-endpoint response body.
The token's granted scopes, as a list.
Types
Functions
Builds a token from a decoded token-endpoint response body.
Returns :error when the body is not a map or carries no usable
access_token.
Examples
iex> {:ok, token} =
...> Ueberauth.Strategy.IntervalsIcu.Token.from_response(%{
...> "token_type" => "Bearer",
...> "access_token" => "abc123",
...> "scope" => "ACTIVITY:READ,WELLNESS:READ",
...> "athlete" => %{"id" => "2049151", "name" => "David"}
...> })
iex> token.access_token
"abc123"
iex> token.athlete["id"]
"2049151"
iex> Ueberauth.Strategy.IntervalsIcu.Token.from_response(%{"error" => "invalid_grant"})
:error
The token's granted scopes, as a list.
intervals.icu joins scopes with commas, not the spaces used by most OAuth
2.0 providers, so this cannot be a plain String.split/2 on whitespace.
Examples
iex> alias Ueberauth.Strategy.IntervalsIcu.Token
iex> Token.scopes(%Token{scope: "ACTIVITY:READ,WELLNESS:WRITE"})
["ACTIVITY:READ", "WELLNESS:WRITE"]
iex> alias Ueberauth.Strategy.IntervalsIcu.Token
iex> Token.scopes(%Token{scope: nil})
[]