import Finch from '@tryfinch/finch-api';
const client = new Finch();
const createAccessTokenResponse = await client.accessTokens.create({ code: 'code' });
console.log(createAccessTokenResponse.connection_id);from finch import Finch
client = Finch()
create_access_token_response = client.access_tokens.create(
code="code",
)
print(create_access_token_response.connection_id)package main
import (
"context"
"fmt"
"github.com/Finch-API/finch-api-go/v2"
"github.com/Finch-API/finch-api-go/v2/option"
)
func main() {
client := finchgo.NewClient(
option.WithAccessToken("My Access Token"),
option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"),
option.WithClientSecret("My Client Secret"),
)
createAccessTokenResponse, err := client.AccessTokens.New(context.TODO(), finchgo.AccessTokenNewParams{
Code: finchgo.F("code"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", createAccessTokenResponse.ConnectionID)
}
package com.tryfinch.api.example;
import com.tryfinch.api.client.FinchClient;
import com.tryfinch.api.client.okhttp.FinchOkHttpClient;
import com.tryfinch.api.models.AccessTokenCreateParams;
import com.tryfinch.api.models.CreateAccessTokenResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
FinchClient client = FinchOkHttpClient.builder()
.fromEnv()
.accessToken("My Access Token")
.build();
AccessTokenCreateParams params = AccessTokenCreateParams.builder()
.code("code")
.build();
CreateAccessTokenResponse createAccessTokenResponse = client.accessTokens().create(params);
}
}package com.tryfinch.api.example
import com.tryfinch.api.client.FinchClient
import com.tryfinch.api.client.okhttp.FinchOkHttpClient
import com.tryfinch.api.models.AccessTokenCreateParams
import com.tryfinch.api.models.CreateAccessTokenResponse
fun main() {
val client: FinchClient = FinchOkHttpClient.builder()
.fromEnv()
.accessToken("My Access Token")
.build()
val params: AccessTokenCreateParams = AccessTokenCreateParams.builder()
.code("code")
.build()
val createAccessTokenResponse: CreateAccessTokenResponse = client.accessTokens().create(params)
}require "finch_api"
finch = FinchAPI::Client.new(
access_token: "My Access Token",
client_id: "4ab15e51-11ad-49f4-acae-f343b7794375",
client_secret: "My Client Secret"
)
create_access_token_response = finch.access_tokens.create(code: "code")
puts(create_access_token_response)curl --request POST \
--url https://api.tryfinch.com/auth/token \
--header 'Content-Type: <content-type>' \
--header 'Finch-API-Version: <finch-api-version>' \
--data '
{
"code": "<string>",
"client_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"client_secret": "<string>",
"redirect_uri": "<string>"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tryfinch.com/auth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>',
'client_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'client_secret' => '<string>',
'redirect_uri' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: <content-type>",
"Finch-API-Version: <finch-api-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"access_token": "7e965183-9332-423c-9259-3edafb332ad2",
"token_type": "bearer",
"connection_id": "bc3a2af9-ce03-46c4-9142-81abe789c64d",
"customer_id": "1234567890",
"customer_name": "Acme Inc",
"account_id": "ac3a2af9-ce03-46c4-9142-81abe789c64d",
"client_type": "production",
"company_id": "4ab15e51-11ad-49f4-acae-f343b7794375",
"connection_type": "provider",
"products": [
"directory",
"employment",
"individual"
],
"provider_id": "gusto",
"entity_ids": [
"550e8400-e29b-41d4-a716-446655440000",
"6ba7b810-9dad-11d1-80b4-00c04fd430c8",
"6ba7b811-9dad-11d1-80b4-00c04fd430c8"
]
}{
"code": 123,
"name": "<string>",
"finch_code": "<string>",
"message": "<string>"
}Create Access Token
Exchange the authorization code for an access token
import Finch from '@tryfinch/finch-api';
const client = new Finch();
const createAccessTokenResponse = await client.accessTokens.create({ code: 'code' });
console.log(createAccessTokenResponse.connection_id);from finch import Finch
client = Finch()
create_access_token_response = client.access_tokens.create(
code="code",
)
print(create_access_token_response.connection_id)package main
import (
"context"
"fmt"
"github.com/Finch-API/finch-api-go/v2"
"github.com/Finch-API/finch-api-go/v2/option"
)
func main() {
client := finchgo.NewClient(
option.WithAccessToken("My Access Token"),
option.WithClientID("4ab15e51-11ad-49f4-acae-f343b7794375"),
option.WithClientSecret("My Client Secret"),
)
createAccessTokenResponse, err := client.AccessTokens.New(context.TODO(), finchgo.AccessTokenNewParams{
Code: finchgo.F("code"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", createAccessTokenResponse.ConnectionID)
}
package com.tryfinch.api.example;
import com.tryfinch.api.client.FinchClient;
import com.tryfinch.api.client.okhttp.FinchOkHttpClient;
import com.tryfinch.api.models.AccessTokenCreateParams;
import com.tryfinch.api.models.CreateAccessTokenResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
FinchClient client = FinchOkHttpClient.builder()
.fromEnv()
.accessToken("My Access Token")
.build();
AccessTokenCreateParams params = AccessTokenCreateParams.builder()
.code("code")
.build();
CreateAccessTokenResponse createAccessTokenResponse = client.accessTokens().create(params);
}
}package com.tryfinch.api.example
import com.tryfinch.api.client.FinchClient
import com.tryfinch.api.client.okhttp.FinchOkHttpClient
import com.tryfinch.api.models.AccessTokenCreateParams
import com.tryfinch.api.models.CreateAccessTokenResponse
fun main() {
val client: FinchClient = FinchOkHttpClient.builder()
.fromEnv()
.accessToken("My Access Token")
.build()
val params: AccessTokenCreateParams = AccessTokenCreateParams.builder()
.code("code")
.build()
val createAccessTokenResponse: CreateAccessTokenResponse = client.accessTokens().create(params)
}require "finch_api"
finch = FinchAPI::Client.new(
access_token: "My Access Token",
client_id: "4ab15e51-11ad-49f4-acae-f343b7794375",
client_secret: "My Client Secret"
)
create_access_token_response = finch.access_tokens.create(code: "code")
puts(create_access_token_response)curl --request POST \
--url https://api.tryfinch.com/auth/token \
--header 'Content-Type: <content-type>' \
--header 'Finch-API-Version: <finch-api-version>' \
--data '
{
"code": "<string>",
"client_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"client_secret": "<string>",
"redirect_uri": "<string>"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tryfinch.com/auth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>',
'client_id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'client_secret' => '<string>',
'redirect_uri' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: <content-type>",
"Finch-API-Version: <finch-api-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"access_token": "7e965183-9332-423c-9259-3edafb332ad2",
"token_type": "bearer",
"connection_id": "bc3a2af9-ce03-46c4-9142-81abe789c64d",
"customer_id": "1234567890",
"customer_name": "Acme Inc",
"account_id": "ac3a2af9-ce03-46c4-9142-81abe789c64d",
"client_type": "production",
"company_id": "4ab15e51-11ad-49f4-acae-f343b7794375",
"connection_type": "provider",
"products": [
"directory",
"employment",
"individual"
],
"provider_id": "gusto",
"entity_ids": [
"550e8400-e29b-41d4-a716-446655440000",
"6ba7b810-9dad-11d1-80b4-00c04fd430c8",
"6ba7b811-9dad-11d1-80b4-00c04fd430c8"
]
}{
"code": 123,
"name": "<string>",
"finch_code": "<string>",
"message": "<string>"
}Headers
Header used to specify the version for a given API request. Current version is 2020-09-17.
Used to indicate the original media type of the resource
Body
The authorization code received from the authorization server
The client ID for your application
The client secret for your application
The redirect URI used when creating the Connect session. Required if the authorization code came from the redirect flow, and it must match the redirect_uri used to create the session. Omit it if the code came from the embedded flow (Connect SDK).
Response
Access Token
The access token for the connection
The RFC 8693 token type (Finch uses bearer tokens)
The Finch UUID of the connection associated with the access_token
The type of application associated with a token.
development, production, sandbox The type of the connection associated with the token.
provider- connection to an external providerfinch- finch-generated data.
finch, provider An array of the authorized products associated with the access_token
The ID of the provider associated with the access_token
An array of entity IDs that can be accessed with this access token
The ID of your customer you provided to Finch when a connect session was created for this connection
The name of your customer you provided to Finch when a connect session was created for this connection
[DEPRECATED] Use connection_id to identify the connection instead of this account ID
The Finch UUID of the company associated with the access_token.
Was this page helpful?