How to authorize paypal as 3rd party app using developer account (Sandbox)

Aneek
Contributor
Contributor

Hello,

I am trying to integrate with PayPal as third party app inside my platform.

I am using developer account and got my client key and secret, I followed the guides in the following links:

List of scopes: https://developer.paypal.com/docs/log-in-with-paypal/integrate/reference/#scope-attributes

Aouth to login: https://developer.paypal.com/docs/log-in-with-paypal/upgrade/

https://developer.paypal.com/docs/log-in-with-paypal/integrate/

The thing is the aouth link "https://www.sandbox.paypal.com/signin/authorize" responds with => StatusCodeError: 401 - {"error":"invalid_client","error_description":"Client Authentication failed"} .. Could anyone help me with this?

 

Here is the authentication model I am using:

scope : [ 'openid' , 'profile' , 'email' ],


 

            scopeDelimiter : ' ' ,


 

            accountNameFromProfileInfo : context => {


 

                return context . profileInfo [ 'name' ] || context . profileInfo [ 'user_id' ]. toString ();

            },


 

            authUrl : 'https://www.sandbox.paypal.com/signin/authorize' ,

            // authUrl: context => {


 

            //     return 'https://www.sandbox.paypal.com/signin/authorize?' +

            //         `response_type=code&client_id=${context.clientId}` +

            //         `&flowEntry=static` +

            //         `&redirect_uri=${context.callbackUrl}`

            // },


 

            requestAccessToken : context => {


 

                // don't put params into post body, won't work, have to be in query

                let tokenUrl = 'https://api-m.sandbox.paypal.com/v1/oauth2/token?' +

                    'grant_type=authorization_code&code=' + context . authorizationCode +

                    '&redirect_uri=' + context . callbackUrl +

                    '&client_id=' + context . clientId +

                    '&client_secret=' + context . clientSecret ;


 

                return request ({

                    method : 'POST' ,

                    url : tokenUrl ,

                    headers : {

                        'Content-Type' : 'application/x-www-form-urlencoded'

                    },

                    json : true

                }). then ( result => {

                    console . log ( '[[[[[[[Token Result]]]]]]]:' , result );

                    profileInfo = result [ 'data' ];

                    let newDate = new Date ();

                    newDate . setTime ( newDate . getTime () + ( result [ 'expires_in' ] * 1000 ));

                    return {

                        accessToken : result [ 'access_token' ],

                        //refreshToken: result['refresh_token'],

                        accessTokenExpDate : newDate

                    };

                });

            },

 

I have tested the accessToken request through postman using my client key and secret, and it's generated successfully. My issue now how to authorize a login through my platform using developer account?

 

Thanks in advance,

Aya [removed]

Full Stack Developer

Login to Me Too
1 REPLY 1

SyntheticDev
New Community Member

Did you ever solve this?

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.