Struggle retrieving Paypal Access Token using ClientId and Secret 2021

Hi, @Jici do you know how to implement Paypal oAuth2 user authentication?

I spent a week on this, Paypal support is horrible.

What I understand from the Doc, the oAuth2 user auth will only allow you to Get data about the user. So I don’t think it will work for what you need.
I checked with Integromat and it also ask user for Client ID and Consumer Secret. You will need to do the same with your users.

I try to “Onboard Sellers to my Paypal”
Paypal says i need

  1. Generate Access Token
  2. Generate Sign-up link via POST call using Access Token
  3. Give this link to my users so that they can connect their Paypal acocunt.

But what happen is that when my user enters this URL in his browser, he is directed to sandbox.paypal.com and nothing happens.

Can you please help with this? Paypal support is useless

When I tap “F12” after going to this URL, I also get this in CONSOLE:

Can you share more information about your current setting with the url, the POST request … Also, do you get all the onboarding checklist done in your dev account?

@Jici Sorry for a late reply.
I’ve managed to generate valid sign_up URL. It directs me to Sign In With Paypal process and afterwards directs my back to my return_url, which is my app’s workspace page.

There appeared another problem with Paypal documentation.
In their tutorial they say literally that

"When your seller completes the sign-up flow, PayPal returns an authCode and sharedId to your seller’s browser. "
Build onboarding into your software

I have no idea how to get these authCode and sharedId.
Initially, I thought that they would give me them in return_url as parameters, but the return url doesn’t have them. Example of my return_url:

https://appname.com/version-test/workspace?merchantId=testenterprices123122&merchantIdInPayPal=G3NQ8AR7LSH5L&permissionsGranted=false&accountStatus=BUSINESS_ACCOUNT&consentStatus=false&productIntentID=addipmt&productIntentId=addipmt&isEmailConfirmed=false&returnMessage=To%20start%20accepting%20payments,%20please%20log%20in%20to%20PayPal%20and%20finish%20signing%20up.

What is also funny is that Paypal in their tutorial in previous point gives an example of the return_url and it also doesn’t have authCode and sharedId. Build onboarding into your software

Paypal is awful service. I saw on their forum that minumum 4 other people faced same problem as me, and no help to them during the whole year: Partner Referrals API authCode & sharedId missing - PayPal Community

I talked to one coder and he said that maybe redirect should also have its JSON header, but I can’t even imagine how it could exist in Bubble application.

recorded a video explaining the use case https://youtu.be/LsWK5eVc0lo

You will use Get Data from URL in a WF on page load or with a Only when trigger (you can use only when Get Data from page url is not empty). In the Get data, you will be able to select the parameters you need to get data from page url (like merchantIdInPayPal in your example will return: G3NQ8AR7LSH5L)

In your example, you seem to have an error, this is why it didn’t return the expected parameter

1 Like

Just weird, in Paypal’s example they also don’t have expected parameters

If you look doc, there’s another step after the user get redirected by to you app. You need to call another endpoint to complete/check the process. Check for step 5

what do you mean? Do you mean that it’s normal that return url doesn’t include authCode and sharedId, because it includes merchantIdInPayPal that is used in #5 step along with Sellers Access Token?

What can you recommend to me to fix my error? I am lost …

Take a look at these. Step 3. They say “attaches the following query parameters:”. It sounds like “only these parameters”, therefore authCode and sharedId shouldn’t be in URL…

aim to generate sign up link I use JSON code from the example Partner Referrals

the 1st Sample Request, just changed my Access Token and return url

I don’t have time to test and create it myself
but I think that important informations are available at this step:
https://developer.paypal.com/docs/platforms/seller-onboarding/build-onboarding/#2-embed-sign-up-link

1 Like

Do you know how to implement this step #2?
I’ve created HTML element, inserted the script from #2, replaced Action-URL with my Sign-Up url.

Then I tried to go though Paypal onboarding process, but once I came back to redirect_url, I haven’t got the authCode and sharedId.

Am I missing something?

Paypal says
For PayPal to return the authCode and sharedId, you must pass a callback in the data-paypal-onboard-complete attribute. In this example, the onboardedCallback function passed to the data-paypal-onboard-complete attribute sends the authCode and sharedId to the seller's server.

I used their onboardedCallback function, but didn’t get authCode & sharedId in my URL

What I think is that the script will get the authcode and sharedid in the callback function, but you may need to create a plugin or use the JS Toolbox to pass theses values to Bubble after (or a backend WF or a redirect that will add the parameters to url).

What did you try for callback?

1 Like

Hello @Jici . Hearing from you again in this thread is literally like getting unexpected present on my Birth Day. Thank you so much.

I’ve recorded a video and tried to explain how I implement callback. I think it’s more understandable than text messages here https://youtu.be/hKSib_MZS-o

at 03:14 I explain how I implement callback

1 Like

in short, what I tried for implementing callback:

  1. Added whole script from Paypal tutorial as HTML element to my page
    Build onboarding into your software
  2. Tried to call Callback function on the page load.
  3. Tried to add script of the callback in SEO settings of the app, added it to all pages’ header.

Nothing helped. I have 2 assumptions.

  1. Callback function doesn’t work.
  2. It works, but it returns AuthCode and sharedId somewhere, where I am not looking for it. I mean, maybe it returns them in LocalStorage or cookies or somewhere else, I have no idea. Checked DevTools of my browser, found nothing. I just expected to receive AuthCode and SharedId in URL… but from your words it seems that callback should return me AuthCode & SharedId and only after I use “go to page” passing those keys as parameters …

Actually, the callback function is sending a POST request to the url in the script. But this is just an example give by Paypal, You can replace this by an API WF in Bubble. Create a new endpoint that doesn’t requiere auth and send the request there.
You can try to add a console.log to this function with the two parameters available in the callback function to see the result and if the callback is working or not.

1 Like

this POST request in the script is sent to

fetch('/seller-server/login-seller', {

(if I am not wrong!). Actually, I don’t know why they use this certain piece of URL here.
To be honest, I understand how to create endpoint in Bubble with optional auth, but how to “send the request there”? All I have is that I’m redirected from Paypal and Paypal just gave me some useless parameters in the URL.
How to add console.log to “this function” (what is actually “this function”?)?
To be honest, don’t understand what do you mean …