auth - YoYoGames/GMEXT-Twitch GitHub Wiki
Twitch: Authentication
These are the functions of this module:
- twitch_auth
- twitch_auth_exchange_code
- twitch_auth_app_token
- twitch_auth_refresh_token
- twitch_auth_from_cache
- twitch_auth_signout
These are the constants of this module:
Twitch Endpoint: N / A
This function authenticates with Twitch through a web browser.
See: Authentication
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.
Syntax:
twitch_auth(scopes, force_verify=undefined, callback_success, callback_failed)
Argument | Type | Description |
---|---|---|
scopes | Array of TWITCH_SCOPE | The APIs that you're calling identify the scopes you must list. |
force_verify | Boolean | Set to true to force the user to re-authorize your app's access to their resources. The default is false . |
callback_success | Function | Triggered if the request succeeded |
callback_failed | Function | Triggered if the request failed |
Returns:
N/A
Triggers:
These members are returned in the success callback:
Member | Type | Description |
---|---|---|
data | Array | The list of users. |
├── id | String | An ID that identifies the user. |
├── login | String | The user's login name. |
├── display_name | String | The user's display name. |
├── type | String | The type of user. Possible values are: "admin" — Twitch administrator, "global_mod" , "staff" — Twitch staff, "" — Normal user |
├── broadcaster_type | String | The type of broadcaster. Possible values are: "affiliate" — An affiliate broadcaster affiliate broadcaster, "partner" — A partner broadcaster partner broadcaster, "" — A normal broadcaster |
├── description | String | The user's description of their channel. |
├── profile_image_url | String | A URL to the user's profile image. |
├── offline_image_url | String | A URL to the user's offline image. |
├── view_count | Real | The number of times the user's channel has been viewed. NOTE: This field has been deprecated (see Get Users API endpoint – "view_count" deprecation). Any data in this field is not valid and should not be used. |
String | The user's verified email address. The struct includes this field only if the user access token includes the TWITCH_SCOPE: TWITCH_SCOPE_USER_READ_EMAIL . If the request contains more than one user, only the user associated with the access token that provided consent will include an email address — the email address for all other users will be empty. |
|
└── created_at | String | The UTC date and time that the user's account was created. The timestamp is in RFC3339 format. |
This method is triggered on failure.
Twitch Endpoint: N / A
This function authenticates using an exchange code.
Note
This function is used internally by the extension and you don't need to call it yourself. Call twitch_auth to authenticate with Twitch.
See: Authentication
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.
Syntax:
twitch_auth_exchange_code(code, callback_success, callback_failed)
Argument | Type | Description |
---|---|---|
code | String | The code that the /authorize response returned in the code parameter. |
callback_success | Function | Triggered if the request succeeded |
callback_failed | Function | Triggered if the request failed |
Returns:
N/A
Triggers:
These members are returned in the success callback:
Member | Type | Description |
---|---|---|
data | Array | The list of users. |
├── id | String | An ID that identifies the user. |
├── login | String | The user's login name. |
├── display_name | String | The user's display name. |
├── type | String | The type of user. Possible values are: "admin" — Twitch administrator, "global_mod" , "staff" — Twitch staff, "" — Normal user |
├── broadcaster_type | String | The type of broadcaster. The type of broadcaster. Possible values are: "affiliate" — An affiliate broadcaster affiliate broadcaster, "partner" — A partner broadcaster partner broadcaster, "" — A normal broadcaster |
├── description | String | The user's description of their channel. |
├── profile_image_url | String | A URL to the user's profile image. |
├── offline_image_url | String | A URL to the user's offline image. |
├── view_count | Real | The number of times the user's channel has been viewed. NOTE: This field has been deprecated (see Get Users API endpoint – "view_count" deprecation). Any data in this field is not valid and should not be used. |
String | The user's verified email address. The struct includes this field only if the user access token includes the TWITCH_SCOPE: TWITCH_SCOPE_USER_READ_EMAIL . If the request contains more than one user, only the user associated with the access token that provided consent will include an email address — the email address for all other users will be empty. |
|
└── created_at | String | The UTC date and time that the user's account was created. The timestamp is in RFC3339 format. |
This method is triggered on failure.
Twitch Endpoint: N / A
This function authenticates using an app access token.
See: Authentication
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.
Syntax:
twitch_auth_app_token(callback_success, callback_failed)
Argument | Type | Description |
---|---|---|
callback_success | Function | Triggered if the request succeeded |
callback_failed | Function | Triggered if the request failed |
Returns:
N/A
Triggers:
These members are returned in the success callback:
Member | Type | Description |
---|---|---|
data | Array | The list of users. |
├── id | String | An ID that identifies the user. |
├── login | String | The user's login name. |
├── display_name | String | The user's display name. |
├── type | String | The type of user. Possible values are: "admin" — Twitch administrator, "global_mod" , "staff" — Twitch staff, "" — Normal user |
├── broadcaster_type | String | The type of broadcaster. The type of broadcaster. Possible values are: "affiliate" — An affiliate broadcaster affiliate broadcaster, "partner" — A partner broadcaster partner broadcaster, "" — A normal broadcaster |
├── description | String | The user's description of their channel. |
├── profile_image_url | String | A URL to the user's profile image. |
├── offline_image_url | String | A URL to the user's offline image. |
├── view_count | Real | The number of times the user's channel has been viewed. NOTE: This field has been deprecated (see Get Users API endpoint – "view_count" deprecation). Any data in this field is not valid and should not be used. |
String | The user's verified email address. The struct includes this field only if the user access token includes the TWITCH_SCOPE: TWITCH_SCOPE_USER_READ_EMAIL . If the request contains more than one user, only the user associated with the access token that provided consent will include an email address — the email address for all other users will be empty. |
|
└── created_at | String | The UTC date and time that the user's account was created. The timestamp is in RFC3339 format. |
This method is triggered on failure.
Twitch Endpoint: N / A
This function refreshes an access token obtained earlier.
Since the Twitch extension automatically refreshes the access token periodically you shouldn't need to call this function yourself.
See: Authentication
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.
Syntax:
twitch_auth_refresh_token(callback_success, callback_failed)
Argument | Type | Description |
---|---|---|
callback_success | Function | Triggered if the request succeeded |
callback_failed | Function | Triggered if the request failed |
Returns:
N/A
Triggers:
These members are returned in the success callback:
Member | Type | Description |
---|---|---|
data | Array | The list of users. |
├── id | String | An ID that identifies the user. |
├── login | String | The user's login name. |
├── display_name | String | The user's display name. |
├── type | String | The type of user. Possible values are: "admin" — Twitch administrator, "global_mod" , "staff" — Twitch staff, "" — Normal user |
├── broadcaster_type | String | The type of broadcaster. The type of broadcaster. Possible values are: "affiliate" — An affiliate broadcaster affiliate broadcaster, "partner" — A partner broadcaster partner broadcaster, "" — A normal broadcaster |
├── description | String | The user's description of their channel. |
├── profile_image_url | String | A URL to the user's profile image. |
├── offline_image_url | String | A URL to the user's offline image. |
├── view_count | Real | The number of times the user's channel has been viewed. NOTE: This field has been deprecated (see Get Users API endpoint – "view_count" deprecation). Any data in this field is not valid and should not be used. |
String | The user's verified email address. The struct includes this field only if the user access token includes the TWITCH_SCOPE: TWITCH_SCOPE_USER_READ_EMAIL . If the request contains more than one user, only the user associated with the access token that provided consent will include an email address — the email address for all other users will be empty. |
|
└── created_at | String | The UTC date and time that the user's account was created. The timestamp is in RFC3339 format. |
This method is triggered on failure.
Twitch Endpoint: N / A
This function performs authentication using the refresh token saved from a previous session.
It returns the request ID if a cached token is available or -1 otherwise.
Note
This function can only be used if the user authenticated before using twitch_auth.
This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Success Callback, or Failure Callback.
Syntax:
twitch_auth_from_cache(callback_success, callback_failed)
Argument | Type | Description |
---|---|---|
callback_success | Function | Triggered if the request succeeded |
callback_failed | Function | Triggered if the request failed |
Returns:
Triggers:
These members are returned in the success callback:
Member | Type | Description |
---|---|---|
data | Array | The list of users. |
├── id | String | An ID that identifies the user. |
├── login | String | The user's login name. |
├── display_name | String | The user's display name. |
├── type | String | The type of user. Possible values are: "admin" — Twitch administrator, "global_mod" , "staff" — Twitch staff, "" — Normal user |
├── broadcaster_type | String | The type of broadcaster. The type of broadcaster. Possible values are: "affiliate" — An affiliate broadcaster affiliate broadcaster, "partner" — A partner broadcaster partner broadcaster, "" — A normal broadcaster |
├── description | String | The user's description of their channel. |
├── profile_image_url | String | A URL to the user's profile image. |
├── offline_image_url | String | A URL to the user's offline image. |
├── view_count | Real | The number of times the user's channel has been viewed. NOTE: This field has been deprecated (see Get Users API endpoint – "view_count" deprecation). Any data in this field is not valid and should not be used. |
String | The user's verified email address. The struct includes this field only if the user access token includes the TWITCH_SCOPE: TWITCH_SCOPE_USER_READ_EMAIL . If the request contains more than one user, only the user associated with the access token that provided consent will include an email address — the email address for all other users will be empty. |
|
└── created_at | String | The UTC date and time that the user's account was created. The timestamp is in RFC3339 format. |
This method is triggered on failure.
Twitch Endpoint: N / A
This function signs out from Twitch.
See: Authentication
Syntax:
twitch_auth_signout()
Returns:
N/A
Twitch: Twitch Access Token Scopes
This group of macros represents the possible access token scopes.
These constants are referenced by the following functions:
Member | Description |
---|---|
TWITCH_SCOPE_ANALYTICS_READ_EXTENSIONS |
The value "analytics:read:extensions" . View analytics data for the Twitch Extensions owned by the authenticated account. |
TWITCH_SCOPE_ANALYTICS_READ_GAMES |
The value "analytics:read:games" . View analytics data for the games owned by the authenticated account. |
TWITCH_SCOPE_BITS_READ |
The value "bits:read" . View Bits information for a channel. Joins your channel's chatroom as a bot user, and perform chat-related actions as that user. |
TWITCH_SCOPE_CHANNEL_BOT |
The value "channel:bot" . Joins your channel's chatroom as a bot user, and perform chat-related actions as that user. |
TWITCH_SCOPE_CHANNEL_EDIT_COMMERCIAL |
The value "channel:edit:commercial" . Run commercials on a channel. |
TWITCH_SCOPE_CHANNEL_MANAGE_BROADCAST |
The value "channel:manage:broadcast" . Manage a channel's broadcast configuration, including updating channel configuration and managing stream markers and stream tags. |
TWITCH_SCOPE_CHANNEL_MANAGE_EXTENSIONS |
The value "channel:manage:extensions" . Manage a channel's Extension configuration, including activating Extensions. |
TWITCH_SCOPE_CHANNEL_MANAGE_POLLS |
The value "channel:manage:polls" . Manage a channel's polls. |
TWITCH_SCOPE_CHANNEL_MANAGE_PREDICTIONS |
The value "channel:manage:predictions" . View a channel's Channel Points Predictions. |
TWITCH_SCOPE_CHANNEL_MANAGE_RAIDS |
The value "channel:manage:raids" . Manage a channel raiding another channel. |
TWITCH_SCOPE_CHANNEL_MANAGE_REDEMPTIONS |
The value "channel:manage:redemptions" . Manage Channel Points custom rewards and their redemptions on a channel. |
TWITCH_SCOPE_CHANNEL_MANAGE_SCHEDULE |
The value "channel:manage:schedule" . Manage a channel's stream schedule. |
TWITCH_SCOPE_CHANNEL_MANAGE_VIDEOS |
The value "channel:manage:videos" . Manage a channel's videos, including deleting videos. |
TWITCH_SCOPE_CHANNEL_MANAGE_VIPS |
The value "channel:manage:vips" . Add or remove the VIP role from users in your channel. |
TWITCH_SCOPE_CHANNEL_MANAGE_GUEST_STAR |
The value "channel:manage:guest_star" . Manage Guest Star for your channel. |
TWITCH_SCOPE_CHANNEL_MANAGE_MODERATORS |
The value "channel:manage:moderators" . Add or remove the moderator role from users in your channel. |
TWITCH_SCOPE_CHANNEL_READ_EDITORS |
The value "channel:read:editors" . View a list of users with the editor role for a channel. |
TWITCH_SCOPE_CHANNEL_READ_GOALS |
The value "channel:read:goals" . View Creator Goals for a channel. |
TWITCH_SCOPE_CHANNEL_READ_GUEST_STAR |
The value "channel:read:guest_star" . Read Guest Star details for your channel. |
TWITCH_SCOPE_CHANNEL_READ_HYPE_TRAIN |
The value "channel:read:hype_train" . View Hype Train information for a channel. |
TWITCH_SCOPE_CHANNEL_READ_POLLS |
The value "channel:read:polls" . View a channel's polls. |
TWITCH_SCOPE_CHANNEL_READ_PREDICTIONS |
The value "channel:read:predictions" . View a channel's Channel Points Predictions. |
TWITCH_SCOPE_CHANNEL_READ_REDEMPTIONS |
The value "channel:read:redemptions" . View Channel Points custom rewards and their redemptions on a channel. |
TWITCH_SCOPE_CHANNEL_READ_STREAM_KEY |
The value "channel:read:stream_key" . View an authorized user's stream key. |
TWITCH_SCOPE_CHANNEL_READ_SUBSCRIPTIONS |
The value "channel:read:subscriptions" . View a list of all subscribers to a channel and check if a user is subscribed to a channel. |
TWITCH_SCOPE_CHANNEL_MANAGE_ADS |
The value "channel:manage:ads" . Manage ads schedule on a channel. |
TWITCH_SCOPE_CHANNEL_READ_ADS |
The value "channel:read:ads" . Read the ads schedule and details on your channel. |
TWITCH_SCOPE_CHANNEL_READ_VIPS |
The value "channel:read:vips" . Read the list of VIPs in your channel. |
TWITCH_SCOPE_CHANNEL_MODERATE |
The value "channel:moderate" . |
TWITCH_SCOPE_CHANNEL_READ_CHARITY |
The value "channel:read:charity" . Read charity campaign details and user donations on your channel. |
TWITCH_SCOPE_CHAT_EDIT |
The value "chat:edit" . Send chat messages to a chatroom using an IRC connection. |
TWITCH_SCOPE_CHAT_READ |
The value "chat:read" . View chat messages sent in a chatroom using an IRC connection. |
TWITCH_SCOPE_CLIPS_EDIT |
The value "clips:edit" . Manage Clips for a channel. |
TWITCH_SCOPE_MODERATION_READ |
The value "moderation:read" . View a channel's moderation data including Moderators, Bans, Timeouts, and Automod settings. |
TWITCH_SCOPE_MODERATOR_READ_AUTOMOD_SETTINGS |
The value "moderator:read:automod_settings" . View a broadcaster's AutoMod settings. |
TWITCH_SCOPE_MODERATOR_READ_BLOCKED_TERMS |
The value "moderator:read:blocked_terms" . View a broadcaster's list of blocked terms. |
TWITCH_SCOPE_MODERATOR_READ_CHAT_SETTINGS |
The value "moderator:read:chat_settings" . View a broadcaster's chat room settings. |
TWITCH_SCOPE_MODERATOR_READ_FOLLOWERS |
The value "moderator:read:followers" . Read the followers of a broadcaster. |
TWITCH_SCOPE_MODERATOR_READ_CHATTERS |
The value "moderator:read:chatters" . View the chatters in a broadcaster's chat room. |
TWITCH_SCOPE_MODERATOR_READ_UNBAN_REQUESTS |
The value "moderator:read:unban_requests" . View a broadcaster's unban requests. |
TWITCH_SCOPE_MODERATOR_READ_GUEST_STAR |
The value "moderator:read:guest_star" . Read Guest Star details for your channel. |
TWITCH_SCOPE_MODERATOR_READ_SHIELD_MODE |
The value "moderator:read:shield_mode" . View a broadcaster's Shield Mode status. |
TWITCH_SCOPE_MODERATOR_MANAGE_GUEST_STAR |
The value "moderator:manage:guest_star" . Manage Guest Star for channels where you are a Guest Star moderator. |
TWITCH_SCOPE_MODERATOR_MANAGE_BANNED_USERS |
The value "moderator:manage:banned_users" . Ban and unban users. |
TWITCH_SCOPE_MODERATOR_MANAGE_BLOCKED_TERMS |
The value "moderator:manage:blocked_terms" . Manage a broadcaster's list of blocked terms. |
TWITCH_SCOPE_MODERATOR_MANAGE_AUTOMOD |
The value "moderator:manage:automod" . Manage messages held for review by AutoMod in channels where you are a moderator. |
TWITCH_SCOPE_MODERATOR_MANAGE_AUTOMOD_SETTINGS |
The value "moderator:manage:automod_settings" . Manage a broadcaster's AutoMod settings. |
TWITCH_SCOPE_MODERATOR_MANAGE_CHAT_MESSAGES |
The value "moderator:manage:chat_messages" . Delete chat messages in channels where you have the moderator role |
TWITCH_SCOPE_MODERATOR_MANAGE_CHAT_SETTINGS |
The value "moderator:manage:chat_settings" . Manage a broadcaster's chat room settings. |
TWITCH_SCOPE_MODERATOR_MANAGE_UNBAN_REQUESTS |
The value "moderator:manage:unban_requests" . Manage a broadcaster's unban requests. |
TWITCH_SCOPE_MODERATOR_MANAGE_SHIELD_MODE |
The value "moderator:manage:shield_mode" . Manage a broadcaster's Shield Mode status. |
TWITCH_SCOPE_MODERATOR_MANAGE_SHOUTOUTS |
The value "moderator:manage:shoutouts" . Manage a broadcaster's shoutouts. |
TWITCH_SCOPE_MODERATOR_MANAGE_ANNOUNCEMENTS |
The value "moderator:manage:announcements" . Send announcements in channels where you have the moderator role. |
TWITCH_SCOPE_USER_BOT |
The value "user:bot" . Join a specified chat channel as your user and appear as a bot, and perform chat-related actions as your user. |
TWITCH_SCOPE_USER_EDIT |
The value "user:edit" . Manage a user object. |
TWITCH_SCOPE_USER_EDIT_BROADCAST |
The value "user:edit:broadcast" . View and edit a user's broadcasting configuration, including Extension configurations. |
TWITCH_SCOPE_USER_MANAGE_BLOCKED_USERS |
The value "user:manage:blocked_users" . Manage the block list of a user. |
TWITCH_SCOPE_USER_MANAGE_CHAT_COLOR |
The value "user:manage:chat_color" . Update the color used for the user's name in chat. |
TWITCH_SCOPE_USER_MANAGE_WHISPERS |
The value "user:manage:whispers" . Receive whispers sent to your user, and send whispers on your user's behalf. |
TWITCH_SCOPE_USER_READ_BLOCKED_USERS |
The value "user:read:blocked_users" . View the block list of a user. |
TWITCH_SCOPE_USER_READ_BROADCAST |
The value "user:read:broadcast" . View a user's broadcasting configuration, including Extension configurations. |
TWITCH_SCOPE_USER_READ_EMAIL |
The value "user:read:email" . View a user's email address. |
TWITCH_SCOPE_USER_READ_SUBSCRIPTIONS |
The value "user:read:subscriptions" . View if an authorized user is subscribed to specific channels. |
TWITCH_SCOPE_USER_READ_EMOTES |
The value "user:read:emotes" . View emotes available to a user. |
TWITCH_SCOPE_USER_READ_FOLLOWS |
The value "user:read:follows" . View the list of channels a user follows. |
TWITCH_SCOPE_USER_READ_MODERATED_CHANNELS |
The value "user:read:moderated_channels" . Read the list of channels you have moderator privileges in. |
TWITCH_SCOPE_USER_READ_CHAT |
The value "user:read:chat" . Receive chatroom messages and informational notifications relating to a channel's chatroom. |
TWITCH_SCOPE_USER_WRITE_CHAT |
The value "user:write:chat" . Send chat messages to a chatroom. |
TWITCH_SCOPE_WHISPERS_READ |
The value "whispers:read" . Receive whisper messages for your user using PubSub. |
TWITCH_SCOPE_WHISPERS_EDIT |
The value "whispers:edit" . |