我试图使用Python使用REST提取销售报告。
access_token和instance_URL为空
我试过给出多个request.post网址,但是没有一个有效。我给出的4个参数是正确的。
import requests
params = {
"grant_type": "password",
"client_id": "XXX.YYY", # Consumer Key
"client_secret": "0000000000000000", # Consumer Secret
"username": "my@email.com", # The email you use to login
"password": "MyPasswordMySecurityToken" # Concat your password and your security token
}
r = requests.post("https://test.salesforce.com/services/oauth2/token",params=params)
access_token = r.json().get("access_token")
instance_url = r.json().get("instance_url")
print("Access Token:", access_token)
print("Instance URL", instance_url)
实际:-
访问令牌:无实例URL无
预期:-实际价值
发布于 2019-04-15 08:30:30
我已经检查了您的代码,它使用了正确的配置参数
这样修改代码并检查错误
sf_response = requests.post("https://test.salesforce.com/services/oauth2/token", params=params)
sf_response_json = sf_response.json()
if "error" in sf_response_json:
print(sf_response_json.get("error"))
print(sf_response_json.get("error_description"))
else:
access_token = sf_response_json.get("access_token")
instance_url = sf_response_json.get("instance_url")
print("Access Token:", access_token)
print("Instance URL", instance_url)
当不正确的pass+sectoken通过时
invalid_grant 认证失败
对于我得到的无效客户身份
invalid_client_id 客户标识符无效
对于无效的客户端秘密:
invalid_client 无效客户端凭据
https://stackoverflow.com/questions/55683712
复制相似问题