Skip to main content
API Reference
Cards
OAuth Tokens

A token that is returned to your application when a user completes the OAuth flow and may be used to authenticate requests. Learn more about OAuth here.

The OAuth Token object
{
  "access_token": "12345",
  "group_id": "group_1g4mhziu6kvrs3vz35um",
  "token_type": "bearer",
  "type": "oauth_token"
}
Attributes
access_token
string

You may use this token in place of an API key to make OAuth requests on a user’s behalf.

group_id
string

The Group’s identifier. A Group is the top-level organization in Increase.

More about Groups.
token_type
string

The type of OAuth token.

type
string

A constant representing the object’s type. For this resource it will always be oauth_token.

Create an OAuth Token
curl -X "POST" \
  --url "${INCREASE_URL}/oauth/tokens" \
  -H "Authorization: Bearer ${INCREASE_API_KEY}" \
  -H "Content-Type: application/json" \
  -d $'{
    "client_id": "12345",
    "client_secret": "supersecret",
    "code": "123",
    "grant_type": "authorization_code"
  }'
import Increase from 'increase';

const client = new Increase({
  apiKey: process.env['INCREASE_API_KEY'], // This is the default and can be omitted
});

const oauthToken = await client.oauthTokens.create({ grant_type: 'authorization_code' });

console.log(oauthToken.group_id);
import os
from increase import Increase

client = Increase(
    api_key=os.environ.get("INCREASE_API_KEY"),  # This is the default and can be omitted
)
oauth_token = client.oauth_tokens.create(
    grant_type="authorization_code",
)
print(oauth_token.group_id)
require "increase"

increase = Increase::Client.new(
  api_key: ENV["INCREASE_API_KEY"] # This is the default and can be omitted
)

oauth_token = increase.oauth_tokens.create(grant_type: :authorization_code)

puts(oauth_token)
package main

import (
	"context"
	"fmt"
	"os"

	"github.com/Increase/increase-go"
	"github.com/Increase/increase-go/option"
)

func main() {
	client := increase.NewClient(
		option.WithAPIKey(os.Getenv("INCREASE_API_KEY")), // This is the default and can be omitted
	)
	oauthToken, err := client.OAuthTokens.New(context.TODO(), increase.OAuthTokenNewParams{
		GrantType: increase.F(increase.OAuthTokenNewParamsGrantTypeAuthorizationCode),
	})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", oauthToken.GroupID)
}
package com.increase.api.example;

import com.increase.api.client.IncreaseClient;
import com.increase.api.client.okhttp.IncreaseOkHttpClient;
import com.increase.api.models.oauthtokens.OAuthToken;
import com.increase.api.models.oauthtokens.OAuthTokenCreateParams;

public final class Main {
    private Main() {}

    public static void main(String[] args) {
        IncreaseClient client = IncreaseOkHttpClient.fromEnv();

        OAuthTokenCreateParams params = OAuthTokenCreateParams.builder()
            .grantType(OAuthTokenCreateParams.GrantType.AUTHORIZATION_CODE)
            .build();
        OAuthToken oauthToken = client.oauthTokens().create(params);
    }
}
package com.increase.api.example

import com.increase.api.client.IncreaseClient
import com.increase.api.client.okhttp.IncreaseOkHttpClient
import com.increase.api.models.oauthtokens.OAuthToken
import com.increase.api.models.oauthtokens.OAuthTokenCreateParams

fun main() {
    val client: IncreaseClient = IncreaseOkHttpClient.fromEnv()

    val params: OAuthTokenCreateParams = OAuthTokenCreateParams.builder()
        .grantType(OAuthTokenCreateParams.GrantType.AUTHORIZATION_CODE)
        .build()
    val oauthToken: OAuthToken = client.oauthTokens().create(params)
}
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';

use Increase\Client;
use Increase\Core\Exceptions\APIException;

$client = new Client(apiKey: getenv('INCREASE_API_KEY'));

try {
  $oauthToken = $client->oauthTokens->create(
    grantType: 'authorization_code',
    clientID: '12345',
    clientSecret: 'supersecret',
    code: '123',
    productionToken: 'x',
  );

  var_dump($oauthToken);
} catch (APIException $e) {
  echo $e->getMessage();
}
using System;
using Increase.Api;
using Increase.Api.Models.OAuthTokens;

IncreaseClient client = new();

OAuthTokenCreateParams parameters = new()
{
    GrantType = GrantType.AuthorizationCode
};

var oauthToken = await client.OAuthTokens.Create(parameters);

Console.WriteLine(oauthToken);
Parameters
client_id
string

The public identifier for your application.

Between 1 and 200 characters
client_secret
string

The secret that confirms you own the application. This is redundant given that the request is made with your API key but it’s a required component of OAuth 2.0.

Between 1 and 200 characters
code
string

The authorization code generated by the user and given to you as a query parameter.

Between 1 and 200 characters
grant_type
enum
Required

The credential you request in exchange for the code. In Production, this is always authorization_code. In Sandbox, you can pass either enum value.

production_token
string

The production token you want to exchange for a sandbox token. This is only available in Sandbox. Set grant_type to production_token to use this parameter.

Between 1 and 200 characters