通过Twitch API将用户下载到我的抽搐中
我正在尝试获取通过Twitch API订阅Twitch频道的用户列表,我已经设置了获取访问令牌的请求,然后我拨打api/helix/subpcriptions/caster in access occess token in occess token订户列表,但是我一直遇到无法获得成功请求的同一问题。
请求未经授权的状态代码失败
var options = new RestClientOptions("https://id.twitch.tv/oauth2/token")
{
ThrowOnAnyError = true,
Timeout = 1000
};
var client = new RestClient(options);
var request = new RestRequest()
.AddQueryParameter("grant_type", "client_credentials")
.AddQueryParameter("client_id", clientId)
.AddQueryParameter("client_secret", clientSecret);
var response = await client.PostAsync(request);
var result = JsonConvert.DeserializeObject<OauthToken>(response.Content);
var userOptions = new RestClientOptions("https://api.twitch.tv/helix/subscriptions");
var clientR2 = new RestClient(userOptions);
var requestR2 = new RestRequest()
.AddHeader("Authorization", "Bearer " + result.access_token)
.AddHeader("Client-Id", clientId)
.AddQueryParameter("broadcaster_id", broadcasterId);
var responseR2 = await clientR2.GetAsync(requestR2);
我不确定是否可以使用,我已经介绍了大多数Twitch API文档,并且我有类似的设置与仅获得“用户”,但是即使使用类似的参数,订阅似乎也无法正常工作。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在使用错误的OAuth流。
您需要一个代表用户的令牌,
client_credentials
广义地说不代表用户,而是“服务器”。因此,使用令牌,您无权阅读
broadcasterid
订阅。因此,未经授权的状态代码失败了403/请求在此处阅读更多有关官方文档:
您需要一个response_type
code> code> code
或token
not /代码>You are using the wrong oAuth flow.
You need a token that representes a user,
client_credentials
broadly speaking doesn't represent a user but a "server".So with your token you do not have permission to read
broadcasterId
subscriptions. Hence the 403/Request failed with status code UnauthorizedRead more on the official documentation here: https://dev.twitch.tv/docs/authentication#user-access-tokens
You need a response_type
code
ortoken
notclient_credentials