-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaccess-tokens.ts
More file actions
136 lines (117 loc) · 3.43 KB
/
access-tokens.ts
File metadata and controls
136 lines (117 loc) · 3.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import type { RequestOptions } from '../internal/request-options';
import type { APIPromise } from '../core/api-promise';
import { APIResource } from '../core/resource';
export class AccessTokens extends APIResource {
/**
* Exchange the authorization code for an access token
*/
create(body: AccessTokenCreateParams, options?: RequestOptions): APIPromise<CreateAccessTokenResponse> {
const clientID = body.client_id || this._client.clientID;
if (!clientID)
throw new Error(
'client_id must be provided as an argument or with the FINCH_CLIENT_ID environment variable',
);
const clientSecret = body.client_secret || this._client.clientSecret;
if (!clientSecret)
throw new Error(
'client_secret must be provided as an argument or with the FINCH_CLIENT_SECRET environment variable',
);
const bodyWithReplacements = {
...body,
client_id: clientID,
client_secret: clientSecret,
};
const headersWithReplacements = {
...options?.headers,
authorization: null,
};
return this._client.post('/auth/token', {
body: bodyWithReplacements,
...options,
headers: headersWithReplacements,
__security: {},
});
}
}
export interface CreateAccessTokenResponse {
/**
* The access token for the connection
*/
access_token: string;
/**
* The type of application associated with a token.
*/
client_type: 'development' | 'production' | 'sandbox';
/**
* The Finch UUID of the connection associated with the `access_token`
*/
connection_id: string;
/**
* The type of the connection associated with the token.
*
* - `provider` - connection to an external provider
* - `finch` - finch-generated data.
*/
connection_type: 'finch' | 'provider';
/**
* An array of entity IDs that can be accessed with this access token
*/
entity_ids: Array<string>;
/**
* An array of the authorized products associated with the `access_token`
*/
products: Array<string>;
/**
* The ID of the provider associated with the `access_token`
*/
provider_id: string;
/**
* The RFC 8693 token type (Finch uses `bearer` tokens)
*/
token_type: string;
/**
* @deprecated [DEPRECATED] Use `connection_id` to identify the connection instead
* of this account ID
*/
account_id?: string;
/**
* @deprecated [DEPRECATED] Use `connection_id` to identify the connection instead
* of this company ID
*/
company_id?: string;
/**
* The ID of your customer you provided to Finch when a connect session was created
* for this connection
*/
customer_id?: string | null;
/**
* The name of your customer you provided to Finch when a connect session was
* created for this connection
*/
customer_name?: string | null;
}
export interface AccessTokenCreateParams {
/**
* The authorization code received from the authorization server
*/
code: string;
/**
* The client ID for your application
*/
client_id?: string;
/**
* The client secret for your application
*/
client_secret?: string;
/**
* The redirect URI used in the authorization request (optional)
*/
redirect_uri?: string;
}
export declare namespace AccessTokens {
export {
type CreateAccessTokenResponse as CreateAccessTokenResponse,
type AccessTokenCreateParams as AccessTokenCreateParams,
};
}