TwitchApi.Auth (twitch_api v0.2.1)
The Twitch Authentication API
Used to generate app access tokens, and user access tokens
Link to this section Summary
Functions
Get the app access token (https://dev.twitch.tv/docs/authentication#types-of-tokens)
Getting a user_access_token used requires some front-end logic.
Link to this section Functions
get_app_access_token!(client_id, client_secret)
Get the app access token (https://dev.twitch.tv/docs/authentication#types-of-tokens)
The app access tokens expires in 60 days
The client id and secret are app specific and can be found in the twitch development dashboard
Example:
{:ok, %{"access_token" => access_token, "token_type" => token_type, "expires_in" => expires_in}} = get_app_access_token!(client_id, client_secret)
get_user_access_token!(access_token)
Getting a user_access_token used requires some front-end logic.
1: Add a link to your app - https://id.twitch.tv/oauth2/authorize?client_id=XX&redirect_uri=XX&response_type=token&scope=XX
2: The user will authorize there
3: Twitch will call the redirect_uri
Example:
def authorize(conn, %{"access_token" => access_token})
{:ok, %{
"client_id": _,
"login": _,
"scopes": [
"chat:read",
"moderation:read"
],
"user_id": _,
"expires_in": _,
}} = get_user_access_token!(access_token)
end