question

joncloverdev avatar image
joncloverdev asked joncloverdev commented

On First time install of Web App, can the "Open App" button use the redirect_uri passed in from the oauth/authorize call

Hi,

I am following these steps https://docs.clover.com/build/oauth-2-0/#1merch_a... and I have got the flow to work. On the first time call to the oauth/authorize url the Clover user will be asked to login, choose their merchant if needs be and then install the app via the App Marketplace. This works and I understand it.

However I am having an issue identifying which merchant ID is associated with our users. We have multiple users on our site and each will have to install the app, and have a unique merchant ID. I need to store the merchant ID as associated with a user, but I cannot see how to get the OAuth flow to pass back some custom data for me, ie our user ID or some other identifier.

In the settings of the Web App the site url is set as http://localhost:53755/clover (for the sandbox version)

When I call the oauth/authorize url
https://sandbox.dev.clover.com/oauth/authorize?cli...
I make the redirect_uri = http://localhost:53755/clover/OAuth/[UserId], so that I can know which user on my side is trying to install the app.

This works if the user has already installed the app, the call to the oauth/authorize will then use the custom redirect_uri with the [UserID] value.

However, on first install of the app, I don't see a way for the "Open App" button to use the already specified redirect_uri that is present in the URL.

Any assistance would be appreciated on how I can get the flow to return some custom data that I pass on the initial call to oauth/authorize, and that will be used by the "Open App" button on the App Marketplace webpage. I want to avoid the user having to install the app first, and then come back to my side and re-trigger the OAuth process.

Thanks




REST APIOAuth
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

joncloverdev avatar image
joncloverdev answered joncloverdev commented
Thanks for your answer, but I'm not exactly sure how that helps me?

My issue is that the url for "{your_url} " is static and set as part of the Web App settings, or you can set a custom one for the https://sandbox.dev.clover.com/oauth/authorize call using the redirect_uri parameter.

However this redirect_uri parameter is only used on the oauth/authorize call, not on the "Open App" button when the application is installed. The "Open App" button basically navigates to your site and it does not contain any information about which user from my site is trying to open the app. It will contain the merchant ID which is great, but I will be unable to link that merchant ID to a user in my site.

This image shows the chrome dev tools on clicking the "Open App" button, notice there is no redirect_uri being called, even though it is present in the URL of the main window that led the user there...


Hence I have changed my process to first ask the users to install the app via the Clover App Market, and then come back to my site to initiate the oauth authorize call, and as such I am able to create a custom redirect_uri that contains the user identifier I require.

chromesnip.png (20.0 KiB)
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community