How to take token for chat's conversation?

I tried to take chatroom’s conversation content.(I arranged my question.)

I got token by used this URL

Result is below.
“access_token”: “{tokenValue}”,
“refresh_token”: “”,
“scope”: [
“expires_in”: 5272120

So, I used the tokenValue in below source .
[This source’s position is in Get started>Code Samples>Chat>javascript]
window.chatClient = new chatClient({
channel: ‘#{channelid}’,
username: ‘{my_userid}’,
password: ‘oauth:{tokenValue}

So, I couldn’t get chat’s conversation.
But, I could get token in url below.

I don’t know my mistake. What is different something?

I must take token in source(javascript).

How to take token for chat’s conversation?

This example ?

All that example does is generate a leaderboard based on messages in a given time frame

You’d have to modify the code near to do other stuff with a incoming message.

Your token logic is correct, Twitch Chat Password Generator will return a valid token also.

So, what do you actually mean by:

Thank for your quick answer.

Sure, I modified this code to take message in chatroom.

So, I tested 2 way.

I used token received via URL.

It occured “Login authentication failed.”
like below .

But, When I used token received via Twitch Chat OAuth Password Generator. It worked normal.
like below

[Twitch Chat OAuth Password Generator : Twitch Chat Password Generator]

I want to know about my mistake.
Do failed for taking token? or other something?

You need to use one of the grant flows that provides a user access token. An app access token via the client credentials flow will not work.

See Authentication | Twitch Developers under “Getting Tokens”

App access tokens are using to authenticate your application so they cannot take any action on behalf of another user such as logging into chat. They are currently only useful for Drops and higher rate limits in Helix right now.

After getting token at URL below, Need next something step?


Can immediately use token? after add"oauth:"
ex> oauth:{token}

Thank you for your answer.

I called URL to take token. like below{client_id}&redirect_uri={webapplicationuri}&response_type=code&scope=chat_login
This URL is User Access Token.
But I had same result.
( = NOTICE * :Login authentication failed)

Do I have something problem?

Take the resulting access token and run it through:

Make sure chat_login is listed in scopes and the username of the person logging in is in the user_name field. This make check if the token is even valid.

Sorry, I don’t understand.
I am starter about it. So, I ask you to understand.

What is URL’s YOUR_ACCESS_TOKEN ? 1) or 2) ?



After I tested as 1). I called URL that you suggested me.
And I got result like below.
{“error”:“Bad Request”,“status”:400,“message”:“No client id specified”}

I do not think you are fully understanding the OAuth handshake process.

Since you appear to be creating a client side application you want to to use the OAuth Implicit Code Flow.

The general process is as follows:

  1. User opens your application and clicks Login and is directed to:<your client ID>&redirect_uri=http://localhost:3000/public/chatbot.html&response_type=token&scope=chat_login
  2. User accepts the OAuth request via their browser and is redirected back to your application at the redirect_uri
  3. The app access token will be in the URL hash: http://localhost:3000/public/chatbot.html#access_token=XXXXXXX&scope=chat_login
  4. You pull the access_token from the hash and then pass it to your IRC connection logic.

Thank you very much!!

I succeeded test that take chat’s message.

I could resolved because your advice.

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