Skip to main content
Skip table of contents

OAuth2 Datasource

OAuth2 Datasource is a special datasource type, supporting OAuth2 authentication. In this article, we provide a brief tutorial to help you connect PocketQuery to your OAuth2 datasource, such as Slack, Azure, or Google datasources.

Configuration

To configure your connection, navigate to ‘Datasources’ in the PocketQuery administration. In the Datasources Overview, click on the ‘Create’.

Select ‘Rest OAuth2’ Datasource type. This option reveals additional fields that are required for a successful OAuth2 flow.

oauth2datasource.png

1. Base URL

The raw URL of your datasource. When you configure a query associated with this datasource, this URL is used as a base URL for all requests.

2. Test URL

The URL used for a connection test. This is a path to your datasource. When the configuration is complete, you can click on the “Test connection” button to try to connect to the datasource. This URL is then used as a suffix of the “Base URL” [1].

3. Authentication URL

The URL used to authenticate users when they try to access datasource with an outdated (or absent) token. A complete URL path is required here.

5. Client ID

An identification of the client. This information is sent to the Authentication URL [3] whenever an access token expires and its refresh is needed.

6. Client Secret

A Secret that is sent to the Authentication URL [3] whenever an access token expires and its refresh is needed.

7. Refresh Token

A token that is used to generate a new access token. This token is not used to authenticate to the datasource. Whenever an access token expires, this token is sent to the Authentication URL [3] to generate a new access token.

8. Access Token

A token used to authenticate to the datasource. It is sent in every datasource request in “Authentication” request header.

Neither Access Token nor Refresh Token are required fields. If you have an unlimited access token that never expires, you do not need to provide a refresh token. Similarly, if your access tokens have very short duration, you don’t need to insert any. PocketQuery automatically generates an access token by itself, whenever it is missing in the configuration.

9. Scope

A scope that is added to the Authentication URL [3] as query parameter.

OAuth2 Flow

After you provide all the Datasource details, you can test the connection or use the datasource in your query. The OAuth2 flow then works as the following:

Request Tracking

You can track your OAuth2 requests in the Macro debug mode. Whenever your access token is refreshed, you can see the following log records:

Contrarily, when your access token is reused and no refresh is needed, you can see the following:

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.