# Token is good and username is correct, Why is login unsuccessful?

**URL:** <https://staging-discuss.dev.twitch.com/t/token-is-good-and-username-is-correct-why-is-login-unsuccessful/40322>\
**Category:** Chat and IRC\
**Created:** [September 1, 2022, 1:56am UTC](https://staging-discuss.dev.twitch.com/t/token-is-good-and-username-is-correct-why-is-login-unsuccessful/40322 "2022-09-01T01:56:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![terminatorbot6000](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@terminatorbot6000](https://staging-discuss.dev.twitch.com/u/terminatorbot6000)\
**Post date:** [September 1, 2022, 1:56am UTC](https://staging-discuss.dev.twitch.com/t/token-is-good-and-username-is-correct-why-is-login-unsuccessful/40322/1 "2022-09-01T01:56:36Z")

</div>

```auto
const tmi = require('tmi.js');

// Define configuration options
var opts = {
  options: { debug: true },
  identity: {
    username: 'terminatorbot6000',
    password: 'oauth:REMOVEBYMODS'
  },
  channels: [
    'op3n_signal'
  ]
};

// Create a client with our options
const client = new tmi.client(opts);

// Connect to Twitch:
client.connect().catch(console.error);

```

I validated the Auth token, I have an account for the bot. I did everything according to the quick start guide to the T. It just says login successful. I can give more details if needed.

This works without the username and password given, of course. But when i give set the identity section, it just says login unseccessful

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [September 1, 2022, 1:58am UTC](https://staging-discuss.dev.twitch.com/t/token-is-good-and-username-is-correct-why-is-login-unsuccessful/40322/2 "2022-09-01T01:58:39Z")

</div>

1. Never post your token publically. They are passwords. You should revoke this token and regenerate
2. Your token doesn’t have any chat permissions, so the token is not valid to login to chat with

According to my test tool: [Token Checker | Twitch API Example](https://barrycarlyon.github.io/twitch_misc/examples/token_checker/)

![image](https://d2spem0quai2ol.cloudfront.net/original/3X/f/8/f8770a431cf94793610854af5f8e5dc7027ca97b.png)

(Client ID’s are public but tokens are not)

See [Twitch Access Token Scopes | Twitch Developers](https://dev.twitch.tv/docs/authentication/scopes#chat-and-pubsub-scopes) you likely need/want at least `chat:edit` and `chat:read`

---

<div class="post-metadata">

**Author:** ![terminatorbot6000](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@terminatorbot6000](https://staging-discuss.dev.twitch.com/u/terminatorbot6000)\
**Post date:** [September 3, 2022, 8:53pm UTC](https://staging-discuss.dev.twitch.com/t/token-is-good-and-username-is-correct-why-is-login-unsuccessful/40322/3 "2022-09-03T20:53:57Z")

</div>

Thanks for getting back so early. Quick reply!

I will try this as soon as I can, and yes I slipped my mind when posting the secret on here.

I will update this post once I try it

---

<div class="post-metadata">

**Author:** ![terminatorbot6000](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@terminatorbot6000](https://staging-discuss.dev.twitch.com/u/terminatorbot6000)\
**Post date:** [September 3, 2022, 9:19pm UTC](https://staging-discuss.dev.twitch.com/t/token-is-good-and-username-is-correct-why-is-login-unsuccessful/40322/4 "2022-09-03T21:19:05Z")

</div>

It says ‘invalid scope requested: chat’ when to set the scope to chat:edit and chat:read

---

<div class="post-metadata">

**Author:** ![BarryCarlyon](https://d1d6mrmdu7ztse.cloudfront.net/user_avatar/staging-discuss.dev.twitch.com/barrycarlyon/32/253_2.png) [@BarryCarlyon](https://staging-discuss.dev.twitch.com/u/BarryCarlyon)\
**Post date:** [September 3, 2022, 9:21pm UTC](https://staging-discuss.dev.twitch.com/t/token-is-good-and-username-is-correct-why-is-login-unsuccessful/40322/5 "2022-09-03T21:21:44Z")

</div>

Sounds like you have a encoding error on your oAuth URL

---

<div class="post-metadata">

**Author:** ![system](https://d2spem0quai2ol.cloudfront.net/original/2X/0/05909729875cce3b53e59d5561c4d23bb14948fc.png) [@system](https://staging-discuss.dev.twitch.com/u/system)\
**Post date:** [October 3, 2022, 9:22pm UTC](https://staging-discuss.dev.twitch.com/t/token-is-good-and-username-is-correct-why-is-login-unsuccessful/40322/6 "2022-10-03T21:22:46Z")

</div>

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