gpt4 book ai didi

Requests keeps returning 403 status, even when following evey step from api documentation(请求保持返回403状态,即使遵循API文档中的每个步骤也是如此)

转载 作者:bug小助手 更新时间:2023-10-25 15:25:25 26 4
gpt4 key购买 nike



I'm trying to use Solarman API (which is a very simple API from this website) to make a simple request to access a token, but it keeps returning a 403 code. Am I doing something wrong ?

我试图使用Solarman API(这是本网站提供的一个非常简单的API)来发出访问令牌的简单请求,但它一直返回403代码。我是不是做错了什么?


here's the code I'm trying:

以下是我正在尝试的代码:


import requests




url = 'https://api.solarmanpv.com/account/v1.0/token?appId='+appid+'&language=en'

params = {
'accept': 'application/json',
'appSecret': appsecret,
'password': password,
'username': username
}


response = requests.request('POST',url,params=params)


print(response)

bellow, you can see how documentation demands the request

下面,您可以看到文档是如何要求请求的


enter image description here


and the example given:

并给出了以下示例:


enter image description here


更多回答

How do you know that the username, password & appsecret are valid?

您如何知道用户名、密码和应用程序密码有效?

The stuff you put in params should go as the body of the request. Replace params=params with json=params

你放在PARMS中的东西应该作为请求的正文。将PARAMS=PARAMS替换为JSON=PARAMS

Is your password sha 256?

您的密码是sha256吗?

To answer you all, appsecret is given by the company itself (solarman), username and password are the ones we use to log in, and yes, the password is the encrypted version on this case. I tried replacing params with json and I still get a 403 response. I'm trying to exhaust options here before contacting the company again

为了回答大家的问题,appret是由公司自己(Solarman)提供的,用户名和密码是我们用来登录的,是的,密码是在这个案例中的加密版本。我尝试用json替换pars,但仍然得到403响应。在再次联系公司之前,我正在试着用尽各种选择

优秀答案推荐

This is an old post, but I thought I'd post a solution here in any case.
I added the following header, which seemed to do the trick:

这是一个古老的帖子,但我想无论如何我都会在这里贴出一个解决方案。我添加了以下标题,这似乎起到了作用:


headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7'}

url = baseurl+'account/v1.0/token?appId='+app_id+'&language=en'

data ={'appSecret':key,'email':email, 'password':password}

a = requests.post(url,json=data,headers=headers)

更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com