首先,所有密钥都与SANDBOX环境相关
过去几天我一直在与PayPal REST API抗争,我试图允许我的应用程序的用户登录并允许我访问他们的帐户以执行退款等服务,付款匹配等
到目前为止,我有一个内置浏览器的Winforms应用程序,我将用户重定向到:
他们登录...嵌入式浏览器扫描地址并收集返回的代码'。从这里开始,然后POST到Paypal(/ v1 / identity / openidconnect / tokenservice),其grant_type为' authorization_code'并收集AccessToken和RefreshToken(我想重用)。
这一切都完美无缺,直到我想使用之前的RefreshToken请求另一个AccessToken。
这是返回的JSON对象:
{{
"token_type": "Bearer",
"expires_in": "28800",
"refresh_token": "o_u5L17nQ4takc5ek_6QGMWl2lZA0jQThpMhURowJKNm6lBPFdkaLUzy0VFwXRg9xRA-ApjDkAIZm6hys_Yg1sLyjceaHIlGIKX_grDBeT5fOeEsPFKg6R9lHp8",
"id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJBWGc0ZXlUeUtEQWhZb29CMnJIZ2J0MUZOSElyOU1oNDVFVzBIMUZQeG5PS2t0NGo4TWR5aVRqSnAxRUxSaGYxNVhDN2hBZTlRWXJER19FcSIsImF1dGhfdGltZSI6MTQ2NTgyOTc4MCwiaXNzIjoiaHR0cHM6Ly93d3cucGF5cGFsLmNvbSIsInNlc3Npb25JbmRleCI6IjIyYjJmNzRkMDA2YzExY2I4N2U3ZGZkY2Q3YjJjNWU0M2RhODljNDYiLCJpYXQiOjE0NjU4Mjk3ODUsImV4cCI6Mjg4MDAsInVzZXJfaWQiOiJodHRwczovL3d3dy5wYXlwYWwuY29tL3dlYmFwcHMvYXV0aC9pZGVudGl0eS91c2VyL0F6V0VmSUtFdE1ldU1SN3laYS1LbkhOSTBPU2x1S2E1N1hVY082VE5sQ1EifQ==.q-JCp-d93CCaS0TgCdMqi9yVmHMzyAID7SbI7O81YwY",
"access_token": "A015mqkkXEVVq0Va0BexS.hhQE0Dlzm36eKNS8-4CVLiIZs"
}}
ChildrenTokens: Count = 5
Count: 5
First: {"token_type": "Bearer"}
HasValues: True
Last: {"access_token": "A015mqkkXEVVq0Va0BexS.hhQE0Dlzm36eKNS8-4CVLiIZs"}
[Next]: Nothing
Parent: Nothing
Path: ""
Previous: Nothing
Root: {{
"token_type": "Bearer",
"expires_in": "28800",
"refresh_token": "o_u5L17nQ4takc5ek_6QGMWl2lZA0jQThpMhURowJKNm6lBPFdkaLUzy0VFwXRg9xRA-ApjDkAIZm6hys_Yg1sLyjceaHIlGIKX_grDBeT5fOeEsPFKg6R9lHp8",
"id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJBWGc0ZXlUeUtEQWhZb29CMnJIZ2J0MUZOSElyOU1oNDVFVzBIMUZQeG5PS2t0NGo4TWR5aVRqSnAxRUxSaGYxNVhDN2hBZTlRWXJER19FcSIsImF1dGhfdGltZSI6MTQ2NTgyOTc4MCwiaXNzIjoiaHR0cHM6Ly93d3cucGF5cGFsLmNvbSIsInNlc3Npb25JbmRleCI6IjIyYjJmNzRkMDA2YzExY2I4N2U3ZGZkY2Q3YjJjNWU0M2RhODljNDYiLCJpYXQiOjE0NjU4Mjk3ODUsImV4cCI6Mjg4MDAsInVzZXJfaWQiOiJodHRwczovL3d3dy5wYXlwYWwuY29tL3dlYmFwcHMvYXV0aC9pZGVudGl0eS91c2VyL0F6V0VmSUtFdE1ldU1SN3laYS1LbkhOSTBPU2x1S2E1N1hVY082VE5sQ1EifQ==.q-JCp-d93CCaS0TgCdMqi9yVmHMzyAID7SbI7O81YwY",
"access_token": "A015mqkkXEVVq0Va0BexS.hhQE0Dlzm36eKNS8-4CVLiIZs"
}}
[Type]: Object {1}
Results View: Expanding the Results View will enumerate the IEnumerable
Dynamic View: Expanding the Dynamic View will get the dynamic members for the object
就像先前对' / v1 / identity / openidconnect / tokenservice' (这很有效!)我再次POST它,这次使用grant_type为' refresh_token'。这次回复是一个例外:
"Unable to refresh access token - invalid_request - https://developer.paypal.com/docs/api/#errors"}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146233079
HelpLink: Nothing
InnerException: {"The remote server returned an error: (400) Bad Request."}
Message: "Unable to refresh access token - invalid_request - https://developer.paypal.com/docs/api/#errors"
Response: Nothing
Source: "PPTest_RESTSDK"
StackTrace: " at PPTest_RESTSDK.Wrapper.WebRequest.Post(Dictionary`2 Contents, String RelativeURL, String AccessToken) in C:\Development\DELME\_PPTest_RESTSDK\PPTest_RESTSDK\Wrapper.vb:line 432" & vbCrLf & " at PPTest_RESTSDK.Wrapper.RegisterByRefreshToken() in C:\Development\DELME\_PPTest_RESTSDK\PPTest_RESTSDK\Wrapper.vb:line 294"
Status: UnknownError {16}
TargetSite: {System.String Post(System.Collections.Generic.Dictionary`2[System.String,System.String], System.String, System.String)}
为了消除我的代码出错的假设,我使用POSTMAN(Chrome插件)重新创建了这个代码。运行此操作还会重现我所看到的完全相同的错误 - 请参阅下文。
授权是我的"客户端的Base64编码版本:secret"等于:
基本QVhnNGV5VHlLREFoWW9vQjJySGdidDFGTkhJcjlNaDQ1RVcwSDFGUHhuT0trdDRqOE1keWlUakpwMUVMUmhmMTVYQzdoQWU5UVlyREdfRXE6RUlYdklvQ3A1bVNRNDZ4RmhtS2VxbGR4anBzMGNIUkxBdTRFZnJnTXZBN3VRMXBaVFN0dWwyTlE1OVNIcjVydEYyeHZYVUNOOWxCT1FEd1g =
客户端: AXg4eyTyKDAhYooB2rHgbt1FNHIr9Mh45EW0H1FPxnOKkt4j8MdyiTjJp1ELRhf15XC7hAe9QYrDG_EqSecret:EIXvIoCp5mSQ46xFhmKeqldxjps0cHRLAu4EfrgMvA7uQ1pZTStul2NQ59SHr5rtF2xvXUCN9lBOQDwX
这与POSTMAN中的结果相同:
有人可以告诉我,我做错了什么吗?我非常感谢!!