# Unable Generate User Access Token via TwtichCLI , results are simply empty

**URL:** <https://discuss.dev.twitch.com/t/unable-generate-user-access-token-via-twtichcli-results-are-simply-empty/59513>\
**Category:** Chat and IRC\
**Created:** [June 28, 2024, 1:25am UTC](https://discuss.dev.twitch.com/t/unable-generate-user-access-token-via-twtichcli-results-are-simply-empty/59513 "2024-06-28T01:25:29Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiedrying](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tiedrying](https://discuss.dev.twitch.com/u/tiedrying)\
**Post date:** [June 28, 2024, 1:25am UTC](https://discuss.dev.twitch.com/t/unable-generate-user-access-token-via-twtichcli-results-are-simply-empty/59513/1 "2024-06-28T01:25:29Z")

</div>

After properly configuring application (“[http://localhost](http://localhost)”) and using TwitchCLI console command for user scope token

twitch token -u -s “chat:read”

I do get the browser to redirect to authorize via twitch (and I do)

and this is the result, an empty result:

```auto
2024/06/27 18:10:26 Waiting for authorization response ...
2024/06/27 18:10:27 Closing local server ...
2024/06/27 18:10:28 User Access Token:
Refresh Token:
Expires At: 2024-06-28 01:10:28.623112 +0000 UTC
Scopes: []

```

In other words, the process completes with no result that can be used as a token. (the message received is just empty)

Is this a new problem?

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 28, 2024, 12:27pm UTC](https://discuss.dev.twitch.com/t/unable-generate-user-access-token-via-twtichcli-results-are-simply-empty/59513/2 "2024-06-28T12:27:37Z")

</div>

The redirect for the cli is localhost:3000 iirc not straight localhost

> **[Get an access token](https://dev.twitch.tv/docs/cli/token-command/)**
>
> Get an access token

And then something is hitting localhost causing empty/faulted generation

---

<div class="post-metadata">

**Author:** ![tiedrying](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tiedrying](https://discuss.dev.twitch.com/u/tiedrying)\
**Post date:** [June 28, 2024, 1:57pm UTC](https://discuss.dev.twitch.com/t/unable-generate-user-access-token-via-twtichcli-results-are-simply-empty/59513/3 "2024-06-28T13:57:07Z")

</div>

> [@BarryCarlyon](#):
>
> And then something is hitting localhost causing empty/faulted generation

I’m not sure this is suggesting a solution on my end, or Twitch’s.

I have (again) tried “:3000”, but it makes no difference.

Yes, I agree, “something” is causing empty token generation, yet the process is completing in TwtichCLI. So, is there anything to be done from my end, or is this a problem we’re promoting to be addressed on the Twitch side?

---

<div class="post-metadata">

**Author:** ![tiedrying](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tiedrying](https://discuss.dev.twitch.com/u/tiedrying)\
**Post date:** [June 29, 2024, 1:19am UTC](https://discuss.dev.twitch.com/t/unable-generate-user-access-token-via-twtichcli-results-are-simply-empty/59513/4 "2024-06-29T01:19:40Z")

</div>

(SOLUTION) Let’s just say, maybe TwitchCLI and this entire route to gain tokens is one way to provide access to your application, but there are other simpler ways.

As the issue describes, I was just trying to read the irc chat from a Twitch channel. And really, if that’s all, there’s an easier route. Btw, eventually this was all for a Unity application to respond to chat messages as commands, so this tutorial video may be of use to many who find this issue.

[![](https://d2opxh93rbxzdn.cloudfront.net/original/3X/4/5/4529395ded8d8ac6e80c526aa49fe29f26bd87cc.jpeg "How to Connect to Twitch Chat in Your Unity Games!") ](https://www.youtube.com/watch?v=uI6K7tzHYtY)

It is straightforward, “let’s read irc chat from a Twitch channel”, and it authenticates in a likewise straightforward manner: just go to a site while logged in to request and grant access to receive an OAuth token to use with this simple C# client connection system. (no plugins needed)

Simpler is better.

The web endpoint to get such authentication is available from the video description.

'Hope that helps

---

<div class="post-metadata">

**Author:** ![Dist](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/dist/32/7192_2.png) [@Dist](https://discuss.dev.twitch.com/u/Dist)\
**Post date:** [June 29, 2024, 8:26am UTC](https://discuss.dev.twitch.com/t/unable-generate-user-access-token-via-twtichcli-results-are-simply-empty/59513/5 "2024-06-29T08:26:33Z")

</div>

It’s strongly discouraged to use 3rd party token generators. Not only will the tokens be invalidated if anything was to happen to the app, but also that uses the Implicit OAuth flow so there’s no possible way to refresh the token. So there are both security and technical implications for using other peoples token generators.

Legacy apps, such as the one used by that tool, don’t currently expire, as the app was made prior to tokens expiring, but when that gets changed and they do expire that could also kill your tokens with no possibility of refreshing as the Implicit flow doesn’t have a refresh token.

For getting an OAuth token in Unity, the recommend way would be to use the [Device Code Flow](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#device-code-grant-flow) (DCF). This is what the Twitch Game Engine Plugin uses too, and it allows your app to get an OAuth token without needing to run a web server, it can be refreshed when it expires, doesn’t have the same issues that your ‘solution’ has, and doesn’t need a Client Secret, so for client-side apps like Unity it can be distributed in apps without needing to expose any credentials that should be kept secret.

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [June 29, 2024, 8:42am UTC](https://discuss.dev.twitch.com/t/unable-generate-user-access-token-via-twtichcli-results-are-simply-empty/59513/6 "2024-06-29T08:42:00Z")

</div>

> [@tiedrying](#):
>
> (SOLUTION) Let’s just say, maybe TwitchCLI and this entire route to gain tokens is one way to provide access to your application, but there are other simpler ways.

The cli is more a test tool

As when the token dies you need a new one

So as dist suggests you need to implement an oAuth flow. Not use a test tool

---

<div class="post-metadata">

**Author:** ![tiedrying](https://avatars.discourse-cdn.com/v4/letter/t/f14d63/32.png) [@tiedrying](https://discuss.dev.twitch.com/u/tiedrying)\
**Post date:** [June 30, 2024, 4:57pm UTC](https://discuss.dev.twitch.com/t/unable-generate-user-access-token-via-twtichcli-results-are-simply-empty/59513/7 "2024-06-30T16:57:40Z")

</div>

(SOLUTION x2) Thank you for helping. In that case, there is a fine Unity example to gain OAuth tokens with simple namespaces natively available. And, this was easy enough to modify for my purposes, effectively passing the token to the chat connection script linked above once it is received. While the above tutorial and 3rd party app use was helpful to initially develop, this route appears to be the recommended safer route you all mentioned in reply. Again, thank you for helping. [GitHub - TheHellcat/Unity-Twitch-OAuth-Example: A quick example how to do Twitch OAuth using a temp. local "webserver" directly in a Unity project.](https://github.com/TheHellcat/Unity-Twitch-OAuth-Example)

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d3ovvz0v2ajtpu.cloudfront.net/user_avatar/discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [July 1, 2024, 8:45am UTC](https://discuss.dev.twitch.com/t/unable-generate-user-access-token-via-twtichcli-results-are-simply-empty/59513/8 "2024-07-01T08:45:11Z")

</div>

> [@tiedrying](#):
>
> Again, thank you for helping. [GitHub - TheHellcat/Unity-Twitch-OAuth-Example: A quick example how to do Twitch OAuth using a temp. local “webserver” directly in a Unity project.](https://github.com/TheHellcat/Unity-Twitch-OAuth-Example)

For unity you probably want DCF [Getting OAuth Access Tokens | Twitch Developers](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/#device-code-grant-flow)

This tutorial/repo predates DCF existing as an option

---

<div class="post-metadata">

**Author:** ![system](https://d2opxh93rbxzdn.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://discuss.dev.twitch.com/u/system)\
**Post date:** [July 31, 2024, 8:45am UTC](https://discuss.dev.twitch.com/t/unable-generate-user-access-token-via-twtichcli-results-are-simply-empty/59513/9 "2024-07-31T08:45:41Z")

</div>

Closed on July 31, 2024, 8:45am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
