Authentication Flow - For CDPs/Data Partners

Render Login Page

Within your partner portal, users should click the "Viant Authentication" button to begin the authentication process. This will redirect them to Viant’s secure login page.

Steps:

  1. The user enters their Viant-issued username and password.

  2. Upon successful authentication, an authorization code is generated.

  3. This code is automatically sent to the CDP/Data Partner's redirect URI i.e redirect uri?code=authorization_code

Endpoint

GET /v1/oauth2/login?redirect_uri=<CDP's callback uri>&client_id=<client id>

Parameter NameDescriptionRequired
client_idUnique identifier created by Viant for the CDP/Data partnerYes
redirect_uriThe callback URI endpoint to receive the authorization codeYes
stateRandom string to prevent CSRF attacksOptional
code_challengePKCE security parameter (43--128 characters)Optional
code_challenge_methodMust be "plain" or "S256" if code_challenge is usedOptional

Note: For PKCE implementation guidance, refer to AWS Cognito documentation.


Exchange Code for JWT Token

Once the user is authenticated and redirected, your app must exchange the authorization code for tokens.

Endpoint

POST v1/oauth2/token

Headers:

Authorization: Basic {base64_encoded_client_id:client_secret}

Request Body:

This endpoint supports both JSON and form-encoded request formats:

Content-Type: application/json

Request Payload:
{
  "grant_type": "authorization_code"
  "code" : "eyJjdHkiOiJKV1Q...",
  "redirect_uri": "CDP's callback uri"
}
Content-Type: application/x-www-form-urlencoded

Request Payload:
grant_type=authorization_code&code=eyJjdHkiOiJKV1Q...&redirect_uri=CDP's callback uri

Successful Response:

{ 
  "access_token" : "eyJraWQiOiJLVk....",
  "expires_in" : 86400,
  "id_token" : "eyJraWQiOi....",
  "token_type" : "Bearer"
}
Parameter NameDescriptionRequired
client_idUnique identifier provided by ViantYes
client_secretSecret provided by ViantYes
codeAuthorization code from login flowYes
redirect_uriMust exactly match original redirect URI usedYes
code_verifierRequired only if PKCE was usedOptional

How it works?

After successful authentication, the user is redirected to your specified redirect_uri with an authorization code

  1. Your CDP application extracts the code from the URL
  2. Your application sends this code to this endpoint
  3. The endpoint validates the code and returns the necessary tokens
  4. Your application can then use these tokens to access protected services

Refresh Access Token

Use this endpoint to refresh your access token using the refresh token provided during authentication.

Endpoint: POST /v1/oauth2/token

Headers:

Authorization: Basic {base64_encoded_client_id:client_secret}

Request Body:

Content-Type: application/json

Request Payload:
{
  "grant_type": "refresh_token",
  "refresh_token" : "eyJjdHkiOiJKV1Q..."
}
Content-Type: application/x-www-form-urlencoded

Request Payload:
grant_type=refresh_token&refresh_token=eyJjdHkiOiJKV1Q...

Response (Success):

{ 
  "access_token" : "eyJraWQiOiJLVk....",
  "expires_in" : 86400,
  "id_token" : "eyJraWQiOi....",
  "token_type" : "Bearer"
}

Response (Failure):

{
  "error_description" : "error message",
  "error": "error code"
}