python - 通过 R 访问 prosper.com OAuth 2.0 API
问题描述
我正在尝试以Prosper.com
R 编程语言访问 API。
此任务没有任何在线帮助。
我已将以下 Python 代码翻译成 R:
import requests
url = "https://api.prosper.com/v1/security/oauth/token"
payload = "grant_type=password&client_id=<your_client_id>&client_secret=<your_client_secret>&username=<prosper_account_username>&password=<prosper_account_password>"
headers = { 'accept': "application/json", 'content-type': "application/x-www-form-urlencoded" }
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
这是我从 Python 到 R 的翻译:
# Required Libraries
library(httr)
library(jsonlite)
# All API access information
Prosper_Base_Address <- "https://api.prosper.com/v1"
Request_URL <- "https://api.prosper.com/v1/security/oauth/token"
ClientID_Username <- "<prosper api key>"
ClientSecret_Password <- "<prosper api secret>"
Prosper_Account_Username <- "<username>"
Prosper_Account_Password <- "<password>"
headers <- fromJSON('{ "accept": "application/json", "content-type": "application/x-www-form-urlencoded" }')
payload <- "grant_type=password&client_id=ClientID_Username&client_secret=ClientSecret_Password&username=Prosper_Account_Username&password=Prosper_Account_Password"
# Create the endpoints
prosper_endpoints <- oauth_endpoint(NULL, "authorize", "accessToken",
base_url = "https://api.prosper.com/v1/security/oauth/token")
# Create the request app
prosper_app <- oauth_app("prosper_endpoints",
key = ClientID_Username,
secret = ClientSecret_Password)
# Get OAuth 2.0 credentials
prosper_token <- oauth2.0_token(prosper_endpoints, prosper_app,
config_init = headers,
user_params = payload)
这会收到错误消息:
{
“错误”:“禁止”,“错误描述”:
“拒绝访问”
}
非常感谢您的帮助!
解决方案
推荐阅读
- python - 如何处理机器人框架中的代理身份验证窗口?AutoIt以外的任何解决方案?
- laravel - Laravel:嵌套关系方法
- amazon-web-services - 使用 AWS CLI 命令停止多个 RDS 实例
- python-3.x - 我需要删除从文本文件中提取的所有非字母字符,并将剩余的字母作为单词放入字典中
- flutter - 如何使用 BLoC 模式运行 Flutter 测试(tester.pumpWidget)?
- regex - 如何删除文本中的换行符,并用空格替换它们?
- python - 如何在python中的列表中查找嵌套列表的位置
- javascript - mySQL/Node 错误消息:“忽略传递给连接的无效配置选项:用户名”
- flutter - 如何实现 Stream 以获取每个文档的子集合列表?-扑
- django - 将身份验证添加到 django rest 框架 openapi