How to set up the OAuth flow

Modified on Tue, 26 Sep, 2023 at 8:17 AM

OAuth flow for your app

To integrate your app with NotifyVisitors, you'll need to follow a two-step OAuth process using your partner account (i.e. the account you’ve used to create the app). This process involves:

1. Building the authorization URL to redirect shops

Once you've created your app and obtained a client ID and client secret, you need to generate an authorization code for redirecting shops to NotifyVisitors. Here's how to build the authorization URL:

Format of the Authorization URL:

https://analytics.notifyvisitors.com/api/oauth/authorize?app_client_id=[Your-Client-ID]&app_redirect_uri=[Your-Redirect-URL]

Replace `[Your-Client-ID]` with your actual client ID and `[Your-Redirect-URL]` with the URL you specified during app creation.

For example:

https://analytics.notifyvisitors.com/api/oauth/authorize?app_client_id=4USNMF8KX5BLS560EEG4ADSW/9HCNTN6LF0&app_redirect_uri=https://www.example.com/oauth/callback

After entering this URL in your browser, you will be redirected to the NotifyVisitors panel with a popup window asking to approve the integration.

Upon approval you will be redirected to your specified redirect URL, and the URL will contain an authorization code upon successful authorization. Save this code for the next step.

For example:

https://www.example.com/oauth/callback/?code=REISbESK3dqWWV4TFkwS215SmwMISNGIKdO1ZVEZvMFovenNObDRjU11xSDIDWEFINIVKROUrS29ETOVqQpzL

2. Exchanging the authorization code for a permanent access token

In this step you need to obtain a permanent access token to pass the required API permissions. For this you'll need to exchange the authorization code and your client secret using the following API endpoint:

API endpoint:

https://analytics.notifyvisitors.com/api/oauth/access_token

In the request body, provide the following:

“auth_code”: The authorization code you obtained earlier.

“app_client_secret”: The client secret you got after creating the app.

Upon making this request, you will receive an access token in the response.

Sample access token

{

"status": "success",

"message": "Access token generated.",

"App_access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdXRoX2NvZGUiOiJlalU0V1VSTE1qWm9SelJOWkVweVV5czRVMWx3Vm1kU1lUTkRaME14WkVGS2FYQmlUakpQU0dWVksxVmpaM0l2UTJSVldETnRZMGxxYTJRcldYUkxVSFprUTNOVU1pOHlTa3hFT0hWUkt6WTRXRUZHU2tFOVBRPT0iLCJjbGllbnRfc2VjcmV0IjoiamczWnRwcEF0ck16Mmo1NnpxY1lQMmo3S2MzUFRSTEVqak8zUWhSalJTdnAwIiwidGltZXN0YW1wIjoxNjk1NzE2OTQ3fQ.9zklZzUq8v0qJbBXLlhtg4JgNpUzE8hvdw9icZmt2NY"

}

With the access token in hand, you can now make API calls to access data at NotifyVisitors. You need to fill this access token as bearer authorization token and for the API end point link and data for body, you can find detailed information in the NotifyVisitors API documentation (https://docs.notifyvisitors.com/reference).

Once this 2 step OAuth process is complete, you can submit your app for review. To know more, check out the 4th step of our article “Getting started with App integration: A Comprehensive Guide for Partners

OAuth flow for your customers

After completing the initial OAuth setup process to connect your app, it's essential to establish a simplified OAuth flow for your customers. This allows them to easily access their data within NotifyVisitors from your platform without the need for complex setup. Here's how to do it:

1. Create an Access Button

Begin by creating a button on your platform, such as "Sync Data from NotifyVisitors" or any other preferred name for the button. This button will serve as the gateway for your users to connect their account with NotifyVisitors.

2. Assign the Authorization Link

Link this button to the following authorization URL:

https://analytics.notifyvisitors.com/api/oauth/authorize?app_client_id=[Your-Client-ID]&app_redirect_uri=[Your-Redirect-URL]

Replace `[Your-Client-ID]` with your actual client ID and `[Your-Redirect-URL]` with the URL you specified during the initial app creation.

3. User Authorization Prompt

When a user clicks on this button, they will be redirected to NotifyVisitors, where they will encounter an authorization popup window seeking their permission.

For example, consider an InviteReferrals user attempting to access their data in NotifyVisitors:

- If the user is not already logged in, they will be redirected to the NotifyVisitors login page.

- After logging in, they will encounter the authorization popup.

4. User Approval and Data Retrieval

Upon the user's approval, your app will initiate an API request to NotifyVisitors to retrieve the data authorized by the user. This data can then be seamlessly integrated into your platform.

5. Return to Your Platform

Finally, the user will be automatically redirected back to your platform, allowing them to continue from where they left off.

This simplified OAuth flow streamlines the process for your customers, making it effortless for them to access and utilize their NotifyVisitors data within your platform. It enhances user convenience and ensures a seamless data integration experience.



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article