paypal / paypal-here-sdk-ios-distribution

Add credit card (tap, insert, swipe & key-in) capabilities to your iOS app
Other
81 stars 91 forks source link

paypalhere gets invalid scope, when "APP SETTINGS" are all checked #334

Closed jonathonbyrdziak closed 4 years ago

jonathonbyrdziak commented 4 years ago

Brief

My team is working on a new iOS app that integrates paypal. When I set the scopes to openid address email profile, everything works well to generate a token, so I know the retail node is working.

I try to use the access token in my app and I get the following errors:

DEBUG: [paypalRest] GET https://api-m.sandbox.paypal.com/v1/retail/status (1043ms): 401
ERROR: [paypalRest] Authorization Failed {
  "url": "https://api-m.sandbox.paypal.com/v1/retail/status",
  "response": "{\"headers\":{\"paypal-debug-id\":\"7b3912511496d\",\"Content-Length\":\"223\",\"Content-Type\":\"application/json\",\"Cache-Control\":\"max-age=0, no-cache, no-store, must-revalidate\",\"Date\":\"Thu, 07 May 2020 07:04:09 GMT\"},\"statusCode\":401,\"body\":{\"correlationId\":\"7b3912511496d\",\"errorCode\":600033,\"message\":\"The scope provided is incorrect\",\"developerMessage\":\"This access token is bound to a different scope than the one required.\",\"errorType\":\"oauth/scope_mismatch\"}}"
}

and

DEBUG: [paypalRest] Successfully refreshed token.
DEBUG: [paypalRest] GET https://api-m.sandbox.paypal.com/v1/retail/status (306ms): 401
ERROR: [paypalRest] Received error {
  "errMessage": "domain: retail, code: 600033, message: The scope provided is incorrect, debugId: 29334f2506608, details: "
}

Because of the error above I believe that I need to add paypalhere to my scopes.

When trying to update the scopes in the retail node to openid https://uri.paypal.com/services/paypalattributes/business https://uri.paypal.com/services/paypalhere address email profile I get another error:

Screenshot_2020-05-11 Sorry about that

Here's my setup

Environment Setup

The Oauth App

We've got the paypal retail node setup on heroku.

The Scopes I need

I need the following scopes:

options.scopes = 'openid https://uri.paypal.com/services/paypalattributes/business https://uri.paypal.com/services/paypalhere address email profile';

As copied directly from https://developer.paypal.com/docs/integration/paypal-here/merchant-onboarding/permissions/#permissions-for-transaction-processing

Developer App Settings

I have checked every option in the app settings. Screenshot_2020-05-11 Edit Applications - PayPal Developer(1) Screenshot_2020-05-11 Edit Applications - PayPal Developer(2) Screenshot_2020-05-11 Edit Applications - PayPal Developer(3) Screenshot_2020-05-11 Edit Applications - PayPal Developer(4)

jonathonbyrdziak commented 4 years ago

This was solved by our Account Manager. Apparently PayPal Here (PPH) needs to be enabled for the client_id you're using.

I'm not sure where or how to enable PPH, but he did it for us. Good Luck Y'all!

ppmtscory commented 4 years ago

I was referring to your enablement in the REST App which you show in your screen shot as being checked. Therefore, it may have just been a glitch in the sandbox where, even though you had the box checked, it didn't actually add the scope to the REST App in the background. I will do further testing internally, but like you said, you're good to go now.