简体   繁体   English

贝宝(Paypal)休息访问令牌呼叫的主体是什么格式和内容类型?

[英]What format and content-type is the body of a paypal rest access token call?

I am using Java with Jersey 2.0 client to make a REST call to the paypal REST API. 我正在将Java与Jersey 2.0客户端一起使用,以对Paypal REST API进行REST调用。 According to the API doc, I should be making a post to: https://api.sandbox.paypal.com/v1/oauth2/token with the Accept: application/json and Accept-Language: en_US. 根据API文档,我应该发布一个帖子到: https ://api.sandbox.paypal.com/v1/oauth2/token,并带有Accept:application / json和Accept-Language:en_US。 It also indicates that I should pass in the body grant_type=client_credentials. 它还表明我应该传递主体Grant_type = client_credentials。 I do all this but I keep getting a 406 or 415. What I can't figure out is what the Content-Type of the post call should be? 我做了所有这些,但是仍然收到406或415。我不知道发帖的Content-Type应该是什么? I've tried text/plain, text/html, application/json, form-url-encoded.. nothing seems to get me a token back. 我已经尝试过text / plain,text / html,application / json,form-url-encoded ..似乎没有什么可以让我获得令牌的。 Not sure why their API doc writer didn't include the Content-Type and format of the payload in the documentation. 不确定为什么他们的API文档编写者没有在文档中包括有效内容的Content-Type和格式。 Anyone know what the Content-Type should be for the body of the post? 任何人都知道帖子正文的Content-Type应该是什么?

I'd like to add that when I do any Content-Type other than form-url-encoded, I get back 415, which means mediatype not accepted, however when I pass in anything using form-url-encoded, I get back the 406, which basically tells me the body is not acceptable. 我想补充一点,当我执行除form-url-encoded之外的任何Content-Type时,我会返回415,这表示未接受mediatype,但是当我使用form-url-encoded传递任何内容时,我会返回406,这基本上告诉我身体是不可接受的。

Thanks. 谢谢。

Thanks for bringing up the question. 感谢您提出问题。

There was a recent change in the /token call and requests for an access token need to have the content-type set as application/x-www-form-urlencoded . / token调用最近发生了变化,访问令牌的请求需要将content-type设置为application/x-www-form-urlencoded This is done by default in cURL calls. 默认情况下,这是在cURL调用中完成的。

Updated docs that include a note about this will be going out very soon. 包含有关此注释的更新文档将很快发布。

Inbound the OAuth 2 endpoint only accepts "application/x-www-form-urlencoded" or it will throw a 415, the payload then needs to be properly url encoded. OAuth 2端点的入站仅接受“ application / x-www-form-urlencoded”,否则将抛出415,然后需要对有效负载进行适当的url编码。 Likewise the accepts header needs to contain "application/json", or the service will throw a 406. 同样,accepts标头需要包含“ application / json”,否则服务将抛出406。

For example: 例如:

Headers: Authorization: Basic [base64 encoded] Content-Type: application/x-www-form-urlencoded Accepts: application/json 标头:授权:基本[base64编码]内容类型:application / x-www-form-urlencoded接受:application / json

Payload sample: grant_type=client_credentials&response_type=token 有效负载样本:grant_type = client_credentials&response_type = token

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 GET调用REST API,Accept为text / csv,content-Type为application / json。 应答的形式应该是什么? - GET call on REST API with Accept as text/csv and content-Type as application/json. In what format should the reponse be? 如何创建具有“内容类型”、授权令牌和正文的截击标题? - How to create volley header having 'Content-Type', Authorization Token and body? 带有内容类型的 java REST Assured 响应主体:带有注入的 html 标签的 text/html - java REST Assured response body with Content-Type: text/html with injected html tags WebFlux WebClient:使用一个 REST 服务,它返回一个 JSON 正文,内容类型为“文本/字符串” - WebFlux WebClient: consume a REST service, that returns a JSON body with Content-Type "text/string" 如何在没有内容类型标题的情况下从请求访问请求正文 - how to access request body from request without content-type header in play POST 请求失败(放心测试)预期的响应正文将被验证为 JSON、HTML 或 XML,但没有在响应中定义内容类型。? - POST request fails (rest-assured test) Expected response body to be verified as JSON, HTML or XML but no content-type was defined in the response.? 在 Apache 中获取 Http 主体,如果未提供内容类型,骆驼将无法正常工作 - Get Http body in Apache Camel not working if content-type not presented REST客户端的Content-Type标头引发UnsupportedOperationException - REST client Content-Type header throws UnsupportedOperationException 响应内容类型为“空”。 放心例外 - Response Content-Type was 'null'. Rest assured exception Spring 引导 REST 端点忽略 Content-Type - Spring Boot REST endpoint ignores Content-Type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM