Giter VIP home page Giter VIP logo

Comments (11)

jscoys avatar jscoys commented on July 18, 2024 1

Hey thx a lot, sorry was planning to do it tonight after work... you are too fast for me ;-)

from helix.

jscoys avatar jscoys commented on July 18, 2024

Oh and I tested with the same client-id, app token and secret and I got a ratelimit-rate of 120 with postman with the same endpoint:

ratelimit-limit →120
ratelimit-remaining →119

from helix.

nicklaw5 avatar nicklaw5 commented on July 18, 2024

Do you mind posting the code you're using so that I can replicate your issue. But don't include your tokens, I have my own.

from helix.

nicklaw5 avatar nicklaw5 commented on July 18, 2024

Never mind, I've just replicated the issue. It appears the Authorization header is not being attached to the request.

from helix.

nicklaw5 avatar nicklaw5 commented on July 18, 2024

Actually, this appears to work as expected:

client, err := helix.NewClient(&helix.Options{
	ClientID: "your-client-id",
	UserAccessToken: "your-user-access-token",
})
if err != nil {
	log.Fatal(err)
}

resp, _ := client.GetStreams(&helix.StreamsParams{
	First: 1,
})
fmt.Printf("%+v\n", resp)

Output:

&{ResponseCommon:{StatusCode:200 Error: ErrorStatus:0 ErrorMessage: RateLimit:{Limit:120 Remaining:119 Reset:1528279075} StreamsMetadataRateLimit:{Limit:0 Remaining:0} ClipsCreationRateLimit:{Limit:0 Remaining:0}} Data:{Streams:[{ID:28982088016 UserID:87056709 GameID:29595 CommunityIDs:[] Type:live Title:Mineski vs Vici Gaming China Dota2 Supermajor Playoffs Day 3 (Lower bracket) ViewerCount:60554 StartedAt:2018-06-06 08:17:57 +0000 UTC Language:en ThumbnailURL:https://static-cdn.jtvnw.net/previews-ttv/live_user_pgl_dota2-{width}x{height}.jpg}] Pagination:{Cursor:eyJiIjpudWxsLCJhIjp7Ik9mZnNldCI6MX19}}}

As you can see from the output the rate limit is 120 with 119 requests remaining.

from helix.

jscoys avatar jscoys commented on July 18, 2024

Hello thx for your answer.

In my use case I just want to use the AppAccessToken with getstreams endpoint, so not the useraccesstoken. Can you try to reproduce it with that context?

from helix.

jscoys avatar jscoys commented on July 18, 2024

So here's my code...

I'm taking an appAccessToken:

client, err := helix.NewClient(&helix.Options{
ClientID: myClientID,
ClientSecret: myClientSecret,
})
if err != nil {
// handle error
}

	resp, err := client.GetAppAccessToken()
	if err != nil {
		// handle error
	}

	//fmt.Printf("%+v\n", resp)

	var myAppToken string = resp.Data.AccessToken

And then I'm trying to get streams for a specific game:
client, err := helix.NewClient(&helix.Options{
ClientID: myClientID,
ClientSecret: myClientSecret,
AppAccessToken: myAppToken,
})
if err != nil {
// handle error
}
resp, err := client.GetStreams(&helix.StreamsParams{
First: 100,
GameIDs: []string{streamID},
After: afterPagination,
})
if err != nil {
// handle error
}

In the response I've got a ratelimit of 30... if I do the same request through PostMan I'm getting a 120!

from helix.

nicklaw5 avatar nicklaw5 commented on July 18, 2024

This appears to be the issue: https://github.com/nicklaw5/helix/blob/master/helix.go#L337-L339

We are only attaching the app access token for the Create Entitlement Grants Upload endpoint, as that is the only endpoint that specifies its use. The Twitch docs aren't very helpful. I wasn't aware that it is possible to use app access tokens for other requests.

from helix.

jscoys avatar jscoys commented on July 18, 2024

Yeah i know the doc doesn’t mention it’s possible or other endpoint, I spent time to search and understand myself ;-) so can you add the possibility to specify the appAccessToken? I guess that if your have app and user access token passed you take user one, and if you have only the app you use this one?

from helix.

nicklaw5 avatar nicklaw5 commented on July 18, 2024

Sure can. Did you want to put together a PR yourself? Otherwise I can probably get to it over the weekend?

from helix.

nicklaw5 avatar nicklaw5 commented on July 18, 2024

@jscoys That's been fixed in fc3312c. I've also cut a new release so be sure to update your dependency manager if you use one.

Thanks for reporting it.

from helix.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.