Oauth2 getting PayPal Token with Net Talk - trying to sort this out

Hi all,
I am trying to sort out getting an Oauth2 token from PayPal sandbox. I have my app name and my client ID and my Client Secret. When I run with libcurl it works and I do get a Token.
However, with Oauth (web83.app ) I have it set up with following picture.


I have added the line:

OAuth.Parms.pGrantType = 'client_credentials'

Trace on net talk shows:
[st][3] [netTalk][thread=3] redirecting to https://api-m.sandbox.paypal.com/v1/oauth2/token?client_id=AQZKU_6Gv4zExNDRe5sW2wHub136EgYLNso426Cw_TtcdHsBGaPaJAhqmK9WDFR9aa6h1RK8m8alLlFu&response_type=code&state=1877455197&redirect_uri=https%3A%2F%2Flocalhost%3A88%2Flocalhost&nonce=KB9ECLI4WK5I43FT
[st][3] [netTalk][thread=3] error: 35 Record Not Found

Login fails. Any one with some help on this?
Thanks,
Ron

Did you get the desktop example working with your settings?

Does PayPal support the client credentials form of Oauth?

I am getting the same with my XERO OAuth 2, Bruce is helping to fix this…So maybe just give him some time to fix it.

NOTE: I compiled an external .exe using Python for XERO and that worked 100%

Hi Bruce,
I did set up the Desktop App the correct way and it did not work. It could not log in - it just hung on “trying to connect”. I found that what I needed was the NetTalk CLient. So, I moved over to there. I successfully set up the CURL example and I did successfully get a token.
However, my NT OAuth client kept giving me the error: “Record not found”.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
From PAY Pal developer:

2. Get access token

Exchange your client ID and client secret for an access token. The access token authenticates your app when calling PayPal REST APIs. You can call the PayPal OAuth API in any language. The following examples show you how to get your access token using cURL or Postman:

cURLPostman

cURL

curl -v -X POST "https://api-m.sandbox.paypal.com/v1/oauth2/token" \ -u "CLIENT_ID:CLIENT_SECRET" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "grant_type=client_credentials"

Modify the code

  1. Change CLIENT_ID to your client ID.
  2. Change CLIENT_SECRET to your client secret.

Note: Encode CLIENT_ID:CLIENT_SECRET in Base64 before sending it in the API call.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
So, it looks like it does suppport ‘client_credentials’.

TO me, it looks like NT is trying to log in with Username and password. That is why I put the NT code in this example.
Ron

>> I did set up the Desktop App the correct way and it did not work.

then it was not set up the correct way.

>> It could not log in - it just hung on “trying to connect”. I found that what I needed was the NetTalk Client.

you can go the NetWebClient route, but it is a lot of work, and a lot of steps.
The NetOAuth class is what wraps all that up into a single call.

>> So, I moved over to there. I successfully set up the CURL example and I did successfully get a token.

However, my NT OAuth client kept giving me the error: “Record not found”.

What I recommend you do is set up the Desktop example app with all your settings, then send that to me so I can have a look.
From there I can suggest what you have done wrong.
Also include links to the PayPal OAuth documentatioin - that will have all the necessary URL’s etc.

>> client_credentials
I would be surprised if it worked with client_credentials. Not impossible, but unlikely

Cheers
Bruce

for the record;

      clear(OAuthParms)
      OAuthParms.pServiceName     = 'PayPalSandbox'                                                                     !Sandbox
      OAuthParms.pClientId        = 'A...u'  !Sandbox
      OAuthParms.pClientSecret    = 'E..cc'  !Sandbox
      OAuthParms.pAccessTokenURL  = 'https://api-m.sandbox.paypal.com/v1/oauth2/token'  ! Sandbox

      !OAuthParms.pServiceName     = 'PayPalLive'                                                                       !Live
      !OAuthParms.pClientId        = '??'                                                                               !Live; different to sandbox
      !OAuthParms.pClientSecret    = '??'                                                                               !Live; different to sandbox
      !OAuthParms.pAccessTokenURL = 'https://api-m.paypal.com/v1/oauth2/token'                                          !Live
      
      OAuthParms.pForce           = false                        ! forces a new login, rejects stored login
      OAuthParms.pOAuthVersion    = 2        
      OAuthParms.pGrantType       = 'client_credentials'
      OAuthParms.pAuthMethod      = Net:WebBasicAuthentication
      OAuthParms.pRequestTokenPOST = True
      OAuthParms.pAccessTokenGET   = False
      OAuthParms.pScope            = ''

and yes, color me surprised :slight_smile:

FUrther information:
The above parameters are for the DESKTOP version.
For NetClient version in SANDBOX mode,
the Parameters are the same but:
-you have to set the redirect URL to ' ' in order to get a sandbox token.

Loc:OAuthParms:DropBox.pRedirectURL  = ''  ! for sandbox testing it is  blank -otherwise will get redirect URL does not match error.

Ron

In the example I sent you (and also posted on ClarionHub) there is no .pRedirectURL at all.
It's not needed for client_credentials.