skip to main content
Administering Hybrid Data Pipeline : Integrating Hybrid Data Pipeline with a Google OAuth 2.0 authorization flow to access Google Analytics : Using the OAuth profiles API to create an OAuth profile
  

Try Now

Using the OAuth profiles API to create an OAuth profile

If a user intends to use the Data Sources API to create data sources on a Google Analytics data store, the user must first create an OAuth profile with the OAuth profiles API. The OAuth profiles API permits Hybrid Data Pipeline access to Google Analytics through the creation of an OAuth profile object. The OAuth profile object holds OAuth access and refresh tokens that are initially supplied by Google. These tokens enable Hybrid Data Pipeline to access Google Analytics on behalf of the user. Before a user can create an OAuth profile, he or she must obtain these tokens from Google before executing the POST to create the OAuth profile.
OAuth profiles are created or selected for data sources, and a single OAuth profile can be used for multiple data sources on a Google Analytics data store. Since OAuth profiles are associated with data sources, a user must have the CreateDataSource (1) permission to create a profile.
Once the user has obtained the required access and refresh tokens from Google, he or she may proceed with a POST operation to create an OAuth profile.

POST operation

The POST operation to create an OAuth profile will have the following syntax.
POST https://<myserver>:<port>/api/mgmt/oauthprofiles

Payload definition

The payload used to create the OAuth profile can be defined as follows.

{
"name": "oauth_profile_name",
"oauthAppId": oauth_application_id,
"description": "oauth_profile_description",
"accessToken": "access_token",
"refreshToken": "refresh_token"
}
Parameter
Description
Usage
Valid Values
"name"
The name of the OAuth profile.
Required
The name can contain only alphanumeric characters and the underscore character.
"oauthAppId"
The ID of the OAuth application object.
Required
The automatically generated OAuth application ID.
"description"
A description of the OAuth profile.
Optional
A description provided by the user.
"accessToken"
The access token includes the credential information required to gain access to the Google Analytics API.
Optional
A valid access token.
"refreshToken"
The refresh token is used to generate new access tokens.
Required
A valid refresh token.

Example

The following POST operation creates the Google_User_1 profile.
POST https://MyServer:8443/api/mgmt/oauthprofiles
Request payload
{
"name": "Google_User_1",
"oauthAppId": 17,
"description": "OAuth profile 1",
"accessToken": "111c334445e55",
"refreshToken": "222d88899966fa"
}
Response payload
Status code: 201
Successful response
{
"id": 33,
"name": "Google_User_1",
"oauthAppId": 17,
"description": "OAuth profile 1",
"accessToken": "111c334445e55",
"refreshToken": "222d88899966fa"
}

What to do next

Once a user has created an OAuth profile with Google-supplied access and refresh tokens, the user can proceed with creating a Google Analytics data source with the Data Sources API.