You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmd/token.go
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ import (
17
17
18
18
varisUserTokenbool
19
19
varuserScopesstring
20
+
varforceVerifybool
20
21
varrevokeTokenstring
21
22
varvalidateTokenstring
22
23
varrefreshTokenstring
@@ -39,6 +40,7 @@ func init() {
39
40
40
41
loginCmd.Flags().BoolVarP(&isUserToken, "user-token", "u", false, "Whether to login as a user or getting an app access token.")
41
42
loginCmd.Flags().StringVarP(&userScopes, "scopes", "s", "", "Space separated list of scopes to request with your user token.")
43
+
loginCmd.Flags().BoolVar(&forceVerify, "forceverify", false, "Set Force Verify")
42
44
loginCmd.Flags().StringVarP(&revokeToken, "revoke", "r", "", "Instead of generating a new token, revoke the one passed to this parameter.")
43
45
loginCmd.Flags().StringVarP(&validateToken, "validate", "v", "", "Instead of generating a new token, validate the one passed to this parameter.")
44
46
loginCmd.Flags().StringVarP(&refreshToken, "refresh", "R", "", "Instead of generating a new token, refresh the token associated with the Refresh Token passed to this parameter.")
Copy file name to clipboardExpand all lines: docs/token.md
+27-30Lines changed: 27 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,27 +6,27 @@ The `token` product is used to fetch access tokens for an application
6
6
7
7
## Token Types
8
8
9
-
The Twitch CLI provides access to two types of tokens: App Access Tokens and User Access Tokens.
9
+
The Twitch CLI provides access to two types of tokens: App Access Tokens and User Access Tokens.
10
10
11
-
**App Access Tokens**
11
+
**App Access Tokens**
12
12
13
-
[App Access Tokens](https://dev.twitch.tv/docs/authentication/#app-access-tokens) can access APIs that don't require the user's permission. For example, getting a list of videos.
13
+
[App Access Tokens](https://dev.twitch.tv/docs/authentication/#app-access-tokens) can access APIs that don't require the user's permission. For example, getting a list of videos.
14
14
15
-
**User Access Tokens**
15
+
**User Access Tokens**
16
16
17
17
[User Access Tokens](https://dev.twitch.tv/docs/authentication/#user-access-tokens) provide access to APIs a user must grant permission to. For example, starting or stopping a poll. The specific APIs and functionality granted to a token is defined via [scopes](https://dev.twitch.tv/docs/authentication/scopes/).
18
18
19
19
## Client IDs and Client Secrets
20
20
21
-
Getting Access Tokens requires use of a Client ID and Client Secret which are associated with a Twitch Developer's Application. Creating an application is done by registration. Details on that process [are here](https://dev.twitch.tv/docs/authentication/register-app/). Client IDs are generated automatically when an application is registered. Client Secrets must be generated explicitly. This can be done by visiting [the Developer Applications Console](https://dev.twitch.tv/console/apps), choosing "Manage" for the app, then using the "New Secret" button at the bottom of the page.
21
+
Getting Access Tokens requires use of a Client ID and Client Secret which are associated with a Twitch Developer's Application. Creating an application is done by registration. Details on that process [are here](https://dev.twitch.tv/docs/authentication/register-app/). Client IDs are generated automatically when an application is registered. Client Secrets must be generated explicitly. This can be done by visiting [the Developer Applications Console](https://dev.twitch.tv/console/apps), choosing "Manage" for the app, then using the "New Secret" button at the bottom of the page.
22
22
23
23
Adding the Client ID and Client Secret to the CLI tool is done with:
24
24
25
25
```
26
26
twitch configure
27
27
```
28
28
29
-
Running that starts prompts asking for the credentials.
29
+
Running that starts prompts asking for the credentials.
30
30
31
31
## Fetching App Access Tokens
32
32
@@ -42,7 +42,6 @@ Running that returns a result with the token like:
Fetching User Access Tokens requires setting an _OAuth Redirect URL_. Those URLs are defined on the _Manage_ page for each app in the [Developer's Application Console](https://dev.twitch.tv/console/apps). The twitch CLI uses `http://localhost:3000`. Two important notes when adding that to the OAuth Redirect URLs section:
@@ -52,12 +51,11 @@ Fetching User Access Tokens requires setting an _OAuth Redirect URL_. Those URLs
52
51
53
52
**The User Flag**
54
53
55
-
The `-u` flag is what sets the `token` product to fetch a User Access Token instead of an App Access Token.
56
-
54
+
The `-u` flag is what sets the `token` product to fetch a User Access Token instead of an App Access Token.
57
55
58
56
**Scopes**
59
57
60
-
User Access Tokens use scopes to determine which APIs and features they have access to. The requested scopes are defined via a space separated list following an `-s` flag with the `token` product.
58
+
User Access Tokens use scopes to determine which APIs and features they have access to. The requested scopes are defined via a space separated list following an `-s` flag with the `token` product.
61
59
62
60
The full list of available scopes [here in the Twitch Documentation](https://dev.twitch.tv/docs/authentication/scopes/)
63
61
@@ -69,7 +67,7 @@ A full example fetching a User Access Token with the ability to do shoutouts and
Running that produce some initial output in the terminal and opens a browser to a Twitch authorization page. If you're not already signed in, you'll be asked to do so. When signed-in, the page displays the authorization request including the requested scopes. Clicking the "Authorize" button at the bottom redirects the browser back to the `http://localhost:3000` address where the `twitch` CLI picks it up and complete the process by parsing the data returned in the URL.
70
+
Running that produce some initial output in the terminal and opens a browser to a Twitch authorization page. If you're not already signed in, you'll be asked to do so. When signed-in, the page displays the authorization request including the requested scopes. Clicking the "Authorize" button at the bottom redirects the browser back to the `http://localhost:3000` address where the `twitch` CLI picks it up and complete the process by parsing the data returned in the URL.
73
71
74
72
The browser will display a message like:
75
73
@@ -140,6 +138,7 @@ By default, this uses the Client ID and Client Secret stored in your config file
NOTE: You must update the first entry in the _OAuth Redirect URLs_ section of your app's management page in the [Developer's Application Console](https://dev.twitch.tv/console/apps) to match the new port number. Make sure there is no `/` at the end of the URL (e.g. use `http://localhost:3030` and not `http://localhost:3030/`) and that the URL is the first entry in the list if there is more than one.
162
161
163
-
164
162
## Alternate Host
165
163
166
164
If you'd like to change the hostname for one reason or another (e.g. binding to a local domain), you can use the `--redirect-host` to change the domain. You should _not_ prefix it with `http` or `https`.
167
165
168
-
Example:
166
+
Example:
169
167
170
168
```
171
169
twitch token -u --redirect-host contoso.com
172
170
```
173
171
174
172
NOTE: You must update the first entry in the _OAuth Redirect URLs_ section of your app's management page in the [Developer's Application Console](https://dev.twitch.tv/console/apps) to match the new port number. Make sure there is no `/` at the end of the URL (e.g. use `http://localhost:3030` and not `http://localhost:3030/`) and that the URL is the first entry in the list if there is more than one.
175
173
176
-
177
174
## Errors
178
175
179
176
This error occurs when there's a problem with the OAuth Redirect URLs. Check in the app's management page in the [Developer's Application Console](https://dev.twitch.tv/console/apps) to ensure the first entry is set to `http://localhost:3000`. Specifically, verify that your using `http` and not `https` and that the URL does not end with a `/`. (If you've changed ports with the `-p` flag, ensure those numbers match as well)
@@ -189,24 +186,24 @@ Error Details: Parameter redirect_uri does not match registered URI
189
186
190
187
None.
191
188
192
-
193
189
**Flags**
194
190
195
-
| Flag | Shorthand | Description | Example | Required? (Y/N) |
|`--user-token`|`-u`| Whether to fetch a user token or not. Default is false. |`token -u`| N |
198
-
|`--dcf`|| Uses Device Code Flow for your User Access Token. Can only be used with --user-token |`token -u --dcf`| N |
199
-
|`--scopes`|`-s`| The space separated scopes to use when getting a user token. |`-s "user:read:email user_read"`| N |
200
-
|`--revoke`|`-r`| Instead of generating a new token, revoke the one passed to this parameter. |`-r 0123456789abcdefghijABCDEFGHIJ`| N |
201
-
|`--validate`|`-v`| Instead of generating a new token, validate the one passed to this parameter. |`-v 0123456789abcdefghijABCDEFGHIJ`| N |
202
-
|`--refresh`|`-R`| Instead of generating a new token, refresh the token associated with the Refresh Token passed to this parameter. |`-R ABCDEfghij0123456789abcdefghijABCDEFGHIJ`| N |
203
-
|`--ip`|| Manually set the port to be used for the User Token web server. The default binds to all interfaces. (0.0.0.0) |`--ip 127.0.0.1`| N |
204
-
|`--port`|`-p`| Override/manually set the port for token actions. (The default is 3000) |`-p 3030`| N |
205
-
|`--client-id`|| Override/manually set Client ID for token actions. By default Client ID from CLI config will be used. |`--client-id uo6dggojyb8d6soh92zknwmi5ej1q2`| N |
206
-
|`--secret`|| Override/manually set Client Secret for token actions. By default Client Secret from CLI config will be used. |`--secret yigv8zib6nuczcoy08u8g1nxh6wjgu`| N |
207
-
|`--redirect-host`|| Override/manually set the redirect host token actions. The default is `localhost`|`--redirect-host contoso.com`| N |
191
+
| Flag | Shorthand | Description | Example | Required? (Y/N) |
|`--user-token`|`-u`| Whether to fetch a user token or not. Default is false. |`token -u`| N |
194
+
|`--dcf`|| Uses Device Code Flow for your User Access Token. Can only be used with --user-token |`token -u --dcf`| N |
195
+
|`--forceverify`|| Sets `force_verify` to true, so you can check scopes and which account you are authing as. Can only be used with --user-token |`token -u --forceverify`| N |
196
+
|`--scopes`|`-s`| The space separated scopes to use when getting a user token. |`-s "user:read:email user_read"`| N |
197
+
|`--revoke`|`-r`| Instead of generating a new token, revoke the one passed to this parameter. |`-r 0123456789abcdefghijABCDEFGHIJ`| N |
198
+
|`--validate`|`-v`| Instead of generating a new token, validate the one passed to this parameter. |`-v 0123456789abcdefghijABCDEFGHIJ`| N |
199
+
|`--refresh`|`-R`| Instead of generating a new token, refresh the token associated with the Refresh Token passed to this parameter. |`-R ABCDEfghij0123456789abcdefghijABCDEFGHIJ`| N |
200
+
|`--ip`|| Manually set the port to be used for the User Token web server. The default binds to all interfaces. (0.0.0.0) |`--ip 127.0.0.1`| N |
201
+
|`--port`|`-p`| Override/manually set the port for token actions. (The default is 3000) |`-p 3030`| N |
202
+
|`--client-id`|| Override/manually set Client ID for token actions. By default Client ID from CLI config will be used. |`--client-id uo6dggojyb8d6soh92zknwmi5ej1q2`| N |
203
+
|`--secret`|| Override/manually set Client Secret for token actions. By default Client Secret from CLI config will be used. |`--secret yigv8zib6nuczcoy08u8g1nxh6wjgu`| N |
204
+
|`--redirect-host`|| Override/manually set the redirect host token actions. The default is `localhost`|`--redirect-host contoso.com`| N |
208
205
209
206
## Notes
210
207
211
-
- If you've already authorized the app, the webpage will redirect back immediately without requiring any interaction
212
-
- You'll be asked to fill in the Client ID and Client Secret if you run the `token` product without having already set them
208
+
-If you've already authorized the app, the webpage will redirect back immediately without requiring any interaction
209
+
-You'll be asked to fill in the Client ID and Client Secret if you run the `token` product without having already set them
0 commit comments