question

Robin Walmsley avatar image
Robin Walmsley asked Robin Walmsley commented

Oauth and a Web App

I'm a little lost with OAuth.

I've setup a basic webview that does nothing more than call the URL of a test page on my Web app. So I have a line in my Android App as follows

webview.loadUrl("http://www.example.com/users/clover_login");

The OAuth documentation says this ..

"The OAuth flow begins when a merchant clicks your app’s icon on their Clover merchant dashboard, and results in the merchant landing on your site URL along with a code that your app can use to retrieve the secure token used to access that merchant’s data through the REST API."

Does that mean I should actually have something like this in my Android MainActivity.java?

webview.loadUrl("https://www.example.com/users/clover_login/oauth_callback?code=12345678-9abc-d123-4567-516171819201&merchant_id=EHFABCCE7D1SA&client_id=HENXXTCZ3QP26");

and I would replace the code, merchanid and clientid data with those of my own?

Presumably then in my PHP web app, I would take those parameters / arguments and issue my own call to the Clover OAuth login

Just need to know Im on the right path with this. Because Im finding it difficult to get anything working.. thanks Robin

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

sam avatar image
sam Deactivated answered Robin Walmsley commented

Your app would call https://sandbox.dev.clover.com/oauth/authorize?client_id={your app id}, which will prompt the user to sign-in, after which, they will be redirected to the website your app points to in your app's settings, along with the client/merch/code params.

Big caveat: depending on which Clover device you're using, WebView may behave slightly different due to their different Android versions. On a Mini, this solution may not work as WebView does not render the sign-in page correctly.

1 comment
10 |2000

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

Robin Walmsley avatar image Robin Walmsley commented ·

OK I have changed this

webview.loadUrl("http://www.example.com/users/clover_login");

to this

webview.loadUrl(" https://sandbox.dev.clover.com/oauth/authorize?client_id={my app id}");

and I can confirm that it is now working .. :).

I am running this on a Clover Station. It is the only device we plan to be distributing our application on.

Robin

0 Likes 0 ·

Welcome to the
Clover Developer Community