authenticationpaypaloauthpaypal-sandbox

Paypal auth not behaving correctly


How do I fix these issues with paypal auth urls?

I was trying to run Paypal auth with my web app so I have a button that takes me to a url to sign into Paypal.

I have three issues:

  1. Paypal isn't letting me login even though I'm certain my Paypal email and password are correct.
  2. Paypal is saying "invalid redirect uri" or "invalid scopes" or "unauthorized scopes" when I try to open the auth url I'm creating
  3. When I login with my Paypal sandbox email, it redirects to https://www.sandbox.paypal.com/signin?returnUri=https%3A%2F%2Fsandbox.paypal.com%2Fmep%2Fmerchantredirect instead of my callback uri.

(I've already solved these issues, I'm just writing this for others because Paypal documentation is severely lacking).


Solution

  • 1 . Paypal only allows you to login with sandbox credentials in sandbox mode. Find your credentials in your sandbox app page under "Sandbox account info". It will look like <&some uuid>@business.example.com and a password.

    2.1 For invalid redirect uri: You need to add your redirect uri to your Paypal app. Check "Login with Paypal" and go to "advanced settings". IMPORTANT You don't actually need login with Paypal to authenticate or use the payouts api. I wasted a long time waiting for approval for it before realizing I didn't need it, it's just the Paypal equivalent of "Login with Google" which you probably don't need.

    2.2 For unauthorized scopes: You may be missing a lower level scope. For me, I needed the payouts scope but I was missing the "openid" scope (which seems to just be the auth scope). Obviously also check that you have the scopes enabled in your app dashboard.

    2.3 For invalid scopes: AI sometimes guesses scopes wrong because there isn't an official list anywhere. Here's an unofficial list though: Find list of available scopes for PayPal API

    3 . You have to add www to the front of the url. https://www.sandbox.paypal.com or https://www.paypal.com