Closed danieldraper closed 1 year ago
@danieldraper your Faraday request is calling the incorrect URL: https://api-m.sandbox.paypal.com/oauth2/token
missing the v1
before /oauth2
. The reason is that when you're making the call, you're doing the following:
connection.post("/oauth2/token", ...)
Passing a path that starts with /
is a way to tell Faraday that you want to override the base path specified in the connection initialisation. If you want to keep the v1
, you need to make the request in this way:
connection.post("oauth2/token", ...)
Removing the slash should be enough to make the request work 👍
P.S.: Thank you for the very detailed ticket description, snippets and steps to reproduce 👏 !
🤦 Thanks @iMacTia always the small things.
Basic Info
Issue description
Unsure exactly how to describe the issue, the response would seem to imply the authorization isn't working as expected however I'm not convinced that is the problem.
I've completed the same PayPal request 3 times to verify it does in fact work and this is an issue with Faraday.
The initial attempt uses the example request from the API docs.
Response
Using Ruby Net::HTTP
Response
Using Faraday (I've also attempted setting the headers for
Authorization
andContent-Type
when initializing Faraday)Response
The headers looks good (used a Proxy to capture).
I also compared the Basic auth headers to ensure the values are the same, can confirm the basic auth header generated by Faraday matches basic auth header from Curl and Net::HTTP.
Steps to reproduce
ruby <SCRIPT_NAME>.rb