You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Once the user grants your application access to their ConvertKit account, they'll be redirected to your Redirect URI with an authorization code. For example:
62
-
63
-
`your-redirect-uri?code=<auth_code>`
64
-
65
-
At this point, your application needs to exchange the authorization code for an access token and refresh token.
66
-
67
-
```php
68
-
$result = $api->get_access_token(
69
-
authCode: '<auth_code>',
70
-
redirectURI: '<your_redirect_uri>'
71
-
);
72
-
```
73
-
74
-
`$result` is an array comprising of:
75
-
-`access_token`: The access token, used to make authenticated requests to the API
76
-
-`refresh_token`: The refresh token, used to fetch a new access token once the current access token has expired
77
-
-`created_at`: When the access token was created
78
-
-`expires_in`: The number of seconds from `created_at` that the access token will expire
79
-
80
-
Once you have an access token, re-initialize the API class with it:
81
-
82
-
```php
83
-
// Initialize the API class.
84
-
$api = new \ConvertKit_API\ConvertKit_API(
85
-
clientID: '<your_oauth_client_id>',
86
-
clientSecret: '<your_oauth_client_secret>',
87
-
accessToken: '<your_access_token>'
88
-
);
89
-
```
90
-
91
-
To refresh an access token:
92
-
93
-
```php
94
-
$result = $api->refresh_token(
95
-
refreshToken: '<your_refresh_token>',
96
-
redirectURI: '<your_redirect_uri>'
97
-
);
98
-
```
99
-
100
-
`$result` is an array comprising of:
101
-
-`access_token`: The access token, used to make authenticated requests to the API
102
-
-`refresh_token`: The refresh token, used to fetch a new access token once the current access token has expired
103
-
-`created_at`: When the access token was created
104
-
-`expires_in`: The number of seconds from `created_at` that the access token will expire
105
-
106
-
Once you have refreshed the access token i.e. obtained a new access token, re-initialize the API class with it:
107
-
108
-
```php
109
-
// Initialize the API class.
110
-
$api = new \ConvertKit_API\ConvertKit_API(
111
-
clientID: '<your_oauth_client_id>',
112
-
clientSecret: '<your_oauth_client_secret>',
113
-
accessToken: '<your_new_access_token>'
114
-
);
115
-
```
116
-
117
-
### 1.x (v3 API, API Key and Secret, PHP 7.4+)
118
-
119
37
Get your ConvertKit API Key and API Secret [here](https://app.convertkit.com/account/edit) and set it somewhere in your application.
0 commit comments