Streamlabs API 405 响应代码 [英] Streamlabs API 405 response code

查看:38
本文介绍了Streamlabs API 405 响应代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Streamlabs API.Streamlabs API 使用 Oauth2 来创建应用程序.因此,首先我会将使用我的应用程序的任何人发送到包含我的应用程序的客户端 ID 和我想要使用的范围的授权链接.
(类似于: streamlabs.com/api/v1.0/authorize?client_id=CLIENT-ID-HERE&redirect_uri=REDIRECT-URI&response_type=code&scope=SOME+SCOPES+HERE)

I'm trying to use Streamlabs API. Streamlabs API uses Oauth2 for creating apps. So first I send whoever's using my app to an authorization link containing my app's client id and the scopes I want to use.
(Something like this: streamlabs.com/api/v1.0/authorize?client_id=CLIENT-ID-HERE&redirect_uri=REDIRECT-URI&response_type=code&scope=SOME+SCOPES+HERE)

完成后,我会在指定的重定向 uri 处收到一个代码.然后我使用该代码获取访问令牌以永久访问连接用户的帐户.然后我从一个完美运行的 POST 请求中收到访问令牌......现在我遇到了问题.在访问令牌之前获取临时代码时,我指定了范围:"donations.read +donations.create+alerts.write+alerts.create".

Once I've done that I receive a code at the redirect uri specified. I then use that code to get the access token for permanent access to the connected user's account. I then receive the access token from a POST request that works perfectly... Now I run into the problem. When getting the temporary code before the access token I specified the scopes: "donations.read +donations.create+alerts.write+alerts.create".

在授权时,应用程序会请求对不同范围的许可.焦点范围是 "alerts.write" 以便我可以使用 POST 请求发送测试警报.但这由于某种原因不起作用.要发送测试警报,我必须向此网址发送 POST 请求:"https://streamlabs.com/api/alerts/send_test_alert"

When authorizing, the app asks for permission to the different scopes. The scope in focus is "alerts.write" so that I can send test alerts using POST requests. But this doesn't work for some reason. To send a test alert I have to send a POST request to this url: "https://streamlabs.com/api/alerts/send_test_alert"

我试过用两种不同的方式来做到这一点.
1:

I've tried doing that in two different ways.
1:

import requests

url = "https://streamlabs.com/api/alerts/send_test_alert"

data = {
    "access_token":"UserAccessTokenHere",
    "type":"donation"
}

response = requests.post(url=url, data=data)

print(response.text)  

2:

import requests

url = "https://streamlabs.com/api/alerts/send_test_alert?access_token=UserAccessTokenHere&type=donation"

response = requests.post(url=url)

print(response.text)

如果我执行 print(response),它会打印Response [405]".
但是如果我执行 print(response.text) 我会得到这个页面的长 HTML 文档:错误响应页面

If I do print(response) it prints "Response [405]".
But if I do print(response.text) I get a long HTML document for this page: Error response page

知道我的 Python 请求出了什么问题吗?send_test_alert 文档在这里:链接

Any ideas what's going wrong with my Python requests? send_test_alert documentation here: Link

推荐答案

我已经联系了支持人员,看起来你和我犯了同样的错误.

I've contacted support and looks like you've made the same error as me.

您实际上并未向正确的网址发送请求.
您正在向以下地址发送请求:"https://streamlabs.com/api/alerts/send_test_alert"

You're not actually sending a request to the right URL.
You are a sending a request to: "https://streamlabs.com/api/alerts/send_test_alert"

您应该使用以下 URL:"https://streamlabs.com/api/v1.0/alerts/send_test_alert"

You should be using the URL: "https://streamlabs.com/api/v1.0/alerts/send_test_alert"

这篇关于Streamlabs API 405 响应代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆