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

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

问题描述

我正在尝试使用 Streamlabs API .Streamlabs API使用Oauth2创建应用程序.因此,首先,我将使用我的应用程序的用户发送到授权链接,该链接包含我的应用程序的客户端ID和我要使用的范围.
(这样的事情: streamlabs.com/api/v1.0/authorize?client_id=客户端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请求发送测试警报.但是由于某种原因,这是行不通的.要发送测试警报,我必须向该URL发送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.

您实际上并没有向正确的URL发送请求.
您正在向以下地址发送请求:" 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天全站免登陆