Skip to content

Commit 7c67b2c

Browse files
Merge pull request #282 from pilcrowonpaper/next
Release v3.4.0
2 parents 75c7487 + a61f9e0 commit 7c67b2c

File tree

14 files changed

+648
-2
lines changed

14 files changed

+648
-2
lines changed

.RELEASE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- Add Kick provider ([#277](https://github.com/pilcrowonpaper/arctic/pull/277)).
2+
- Add DonationAlerts provider ([#281](https://github.com/pilcrowonpaper/arctic/pull/281)).
3+
- Add MercadoLibre provider ([#279](https://github.com/pilcrowonpaper/arctic/pull/279)).
4+
- Add MercadoPago provider ([#279](https://github.com/pilcrowonpaper/arctic/pull/279)).

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Arctic does not strictly follow semantic versioning. While we aim to only introd
4444
- Bungie
4545
- Coinbase
4646
- Discord
47+
- DonationAlerts
4748
- Dribbble
4849
- Dropbox
4950
- Etsy
@@ -56,10 +57,14 @@ Arctic does not strictly follow semantic versioning. While we aim to only introd
5657
- Google
5758
- Intuit
5859
- Kakao
60+
- KeyCloak
61+
- Kick
5962
- Lichess
6063
- Line
6164
- Linear
6265
- LinkedIn
66+
- MercadoLibre
67+
- MercadoPago
6368
- Microsoft Entra ID
6469
- MyAnimeList
6570
- Naver

docs/malta.config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
["Bungie", "/providers/bungie"],
3131
["Coinbase", "/providers/coinbase"],
3232
["Discord", "/providers/discord"],
33+
["DonationAlerts", "/providers/donation-alerts"],
3334
["Dribbble", "/providers/dribbble"],
3435
["Dropbox", "/providers/dropbox"],
3536
["Epic Games", "/providers/epicgames"],
@@ -43,10 +44,13 @@
4344
["Intuit", "/providers/intuit"],
4445
["Kakao", "/providers/kakao"],
4546
["KeyCloak", "/providers/keycloak"],
47+
["Kick", "/providers/kick"],
4648
["Lichess", "/providers/lichess"],
4749
["Line", "/providers/line"],
4850
["Linear", "/providers/linear"],
4951
["LinkedIn", "/providers/linkedin"],
52+
["MercadoLibre", "/providers/mercadolibre"],
53+
["MercadoPago", "/providers/mercadopago"],
5054
["Microsoft Entra ID", "/providers/microsoft-entra-id"],
5155
["MyAnimeList", "/providers/myanimelist"],
5256
["Naver", "/providers/naver"],
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
title: "DonationAlerts"
3+
---
4+
5+
# DonationAlerts
6+
7+
OAuth 2.0 provider for DonationAlerts.
8+
9+
Also see the [OAuth 2.0](/guides/oauth2) guide.
10+
11+
## Initialization
12+
13+
```ts
14+
import * as arctic from "arctic";
15+
16+
const donationAlerts = new arctic.DonationAlerts(clientId, clientSecret, redirectURI);
17+
```
18+
19+
## Create authorization URL
20+
21+
```ts
22+
import * as arctic from "arctic";
23+
24+
const state = arctic.generateState();
25+
const scopes = ["oauth-user-show"];
26+
const url = donationAlerts.createAuthorizationURL(state, scopes);
27+
```
28+
29+
## Validate authorization code
30+
31+
`validateAuthorizationCode()` will either return an [`OAuth2Tokens`](/reference/main/OAuth2Tokens), or throw one of [`OAuth2RequestError`](/reference/main/OAuth2RequestError), [`ArcticFetchError`](/reference/main/ArcticFetchError), [`UnexpectedResponseError`](/reference/main/UnexpectedResponseError), or [`UnexpectedErrorResponseBodyError`](/reference/main/UnexpectedErrorResponseBodyError). DonationAlerts returns an access token, the access token expiration, and a refresh token.
32+
33+
```ts
34+
import * as arctic from "arctic";
35+
36+
try {
37+
const tokens = await donationAlerts.validateAuthorizationCode(code);
38+
const accessToken = tokens.accessToken();
39+
const accessTokenExpiresAt = tokens.accessTokenExpiresAt();
40+
const refreshToken = tokens.refreshToken();
41+
} catch (e) {
42+
if (e instanceof arctic.OAuth2RequestError) {
43+
// Invalid authorization code, credentials, or redirect URI
44+
const code = e.code;
45+
// ...
46+
}
47+
if (e instanceof arctic.ArcticFetchError) {
48+
// Failed to call `fetch()`
49+
const cause = e.cause;
50+
// ...
51+
}
52+
// Parse error
53+
}
54+
```
55+
56+
## Refresh access tokens
57+
58+
Use `refreshAccessToken()` to get a new access token using a refresh token. DonationAlerts returns the same values as during the authorization code validation. This method also returns `OAuth2Tokens` and throws the same errors as `validateAuthorizationCode()`
59+
60+
```ts
61+
import * as arctic from "arctic";
62+
63+
try {
64+
const scopes = ["oauth-user-show"];
65+
const tokens = await donationAlerts.refreshAccessToken(refreshToken, scopes);
66+
const accessToken = tokens.accessToken();
67+
const accessTokenExpiresAt = tokens.accessTokenExpiresAt();
68+
} catch (e) {
69+
if (e instanceof arctic.OAuth2RequestError) {
70+
// Invalid authorization code, credentials, or redirect URI
71+
}
72+
if (e instanceof arctic.ArcticFetchError) {
73+
// Failed to call `fetch()`
74+
}
75+
// Parse error
76+
}
77+
```
78+
79+
### Get user profile
80+
81+
Add the `oauth-user-show` scope and use the [`/user/oauth`](https://www.donationalerts.com/apidoc#api_v1__users__user_profile_information) endpoint.
82+
83+
```ts
84+
const scopes = ["oauth-user-show"];
85+
const url = donationAlerts.createAuthorizationURL(state, scopes);
86+
```
87+
88+
```ts
89+
const response = await fetch("https://www.donationalerts.com/api/v1/user/oauth", {
90+
headers: {
91+
Authorization: `Bearer ${accessToken}`
92+
}
93+
});
94+
const user = await response.json();
95+
```

docs/pages/providers/kick.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
---
2+
title: "Kick"
3+
---
4+
5+
# Kick
6+
7+
OAuth 2.0 provider for Kick.
8+
9+
Also see the [OAuth 2.0 with PKCE](/guides/oauth2-pkce) guide.
10+
11+
## Initialization
12+
13+
```ts
14+
import * as arctic from "arctic";
15+
16+
const kick = new arctic.Kick(clientId, clientSecret, redirectURI);
17+
```
18+
19+
## Create authorization URL
20+
21+
```ts
22+
import * as arctic from "arctic";
23+
24+
const state = arctic.generateState();
25+
const codeVerifier = arctic.generateCodeVerifier();
26+
const scopes = ["user:read"];
27+
const url = kick.createAuthorizationURL(state, codeVerifier, scopes);
28+
```
29+
30+
## Validate authorization code
31+
32+
`validateAuthorizationCode()` will either return an [`OAuth2Tokens`](/reference/main/OAuth2Tokens), or throw one of [`OAuth2RequestError`](/reference/main/OAuth2RequestError), [`ArcticFetchError`](/reference/main/ArcticFetchError), [`UnexpectedResponseError`](/reference/main/UnexpectedResponseError), or [`UnexpectedErrorResponseBodyError`](/reference/main/UnexpectedErrorResponseBodyError). Kick returns an access token, the access token expiration, and a refresh token.
33+
34+
```ts
35+
import * as arctic from "arctic";
36+
37+
try {
38+
const tokens = await kick.validateAuthorizationCode(code, codeVerifier);
39+
const accessToken = tokens.accessToken();
40+
const accessTokenExpiresAt = tokens.accessTokenExpiresAt();
41+
const refreshToken = tokens.refreshToken();
42+
} catch (e) {
43+
if (e instanceof arctic.OAuth2RequestError) {
44+
// Invalid authorization code, credentials, or redirect URI
45+
const code = e.code;
46+
// ...
47+
}
48+
if (e instanceof arctic.ArcticFetchError) {
49+
// Failed to call `fetch()`
50+
const cause = e.cause;
51+
// ...
52+
}
53+
// Parse error
54+
}
55+
```
56+
57+
## Refresh access tokens
58+
59+
Use `refreshAccessToken()` to get a new access token using a refresh token. Kick returns the same values as during the authorization code validation. This method also returns `OAuth2Tokens` and throws the same errors as `validateAuthorizationCode()`
60+
61+
```ts
62+
import * as arctic from "arctic";
63+
64+
try {
65+
const tokens = await kick.refreshAccessToken(refreshToken);
66+
const accessToken = tokens.accessToken();
67+
const accessTokenExpiresAt = tokens.accessTokenExpiresAt();
68+
} catch (e) {
69+
if (e instanceof arctic.OAuth2RequestError) {
70+
// Invalid authorization code, credentials, or redirect URI
71+
}
72+
if (e instanceof arctic.ArcticFetchError) {
73+
// Failed to call `fetch()`
74+
}
75+
// Parse error
76+
}
77+
```
78+
79+
### Get user profile
80+
81+
Add the `user:read` scope when creating the authorization URL.
82+
83+
```ts
84+
const scopes = ["user:read"];
85+
const url = kick.createAuthorizationURL(state, codeVerifier, scopes);
86+
```
87+
88+
Then make a request to the Kick REST API with the access token.
89+
90+
```ts
91+
const tokens = await kick.validateAuthorizationCode(code, codeVerifier);
92+
93+
const response = await fetch("https://api.kick.com/public/v1/users", {
94+
headers: {
95+
Authorization: `Bearer ${tokens.accessToken()}`
96+
}
97+
});
98+
const user = await response.json();
99+
```
100+
101+
## Revoke tokens
102+
103+
Pass a token to `revokeToken()` to revoke all tokens associated with the authorization. This can throw the same errors as `validateAuthorizationCode()`.
104+
105+
```ts
106+
try {
107+
await kick.revokeToken(refreshToken);
108+
} catch (e) {
109+
if (e instanceof arctic.OAuth2RequestError) {
110+
// Invalid authorization code, credentials, or redirect URI
111+
}
112+
if (e instanceof arctic.ArcticFetchError) {
113+
// Failed to call `fetch()`
114+
}
115+
// Parse error
116+
}
117+
```
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: "Mercado Libre"
3+
---
4+
5+
# Mercado Libre
6+
7+
OAuth 2.0 provider for Mercado Libre. This client requires PKCE to be enabled in your application settings.
8+
9+
Also see the [OAuth 2.0 with PKCE](/guides/oauth2-pkce) guide.
10+
11+
## Initialization
12+
13+
```ts
14+
import * as arctic from "arctic";
15+
16+
const mercadolibre = new arctic.MercadoLibre(clientId, clientSecret, redirectURI);
17+
```
18+
19+
## Create authorization URL
20+
21+
```ts
22+
import * as arctic from "arctic";
23+
24+
const state = arctic.generateState();
25+
const url = mercadolibre.createAuthorizationURL(state);
26+
```
27+
28+
## Validate authorization code
29+
30+
`validateAuthorizationCode()` will either return an [`OAuth2Tokens`](/reference/main/OAuth2Tokens), or throw one of [`OAuth2RequestError`](/reference/main/OAuth2RequestError), [`ArcticFetchError`](/reference/main/ArcticFetchError), [`UnexpectedResponseError`](/reference/main/UnexpectedResponseError), or [`UnexpectedErrorResponseBodyError`](/reference/main/UnexpectedErrorResponseBodyError). Mercado Libre returns an access token, its expiration, and a refresh token.
31+
32+
```ts
33+
import * as arctic from "arctic";
34+
35+
try {
36+
const tokens = await mercadolibre.validateAuthorizationCode(code);
37+
const accessToken = tokens.accessToken();
38+
const accessTokenExpiresAt = tokens.accessTokenExpiresAt();
39+
const refreshToken = tokens.refreshToken();
40+
} catch (e) {
41+
if (e instanceof arctic.OAuth2RequestError) {
42+
// Invalid authorization code, credentials, or redirect URI
43+
const code = e.code;
44+
// ...
45+
}
46+
if (e instanceof arctic.ArcticFetchError) {
47+
// Failed to call `fetch()`
48+
const cause = e.cause;
49+
// ...
50+
}
51+
// Parse error
52+
}
53+
```
54+
55+
## Refresh access tokens
56+
57+
Add the `offline_access` scope to get a refresh token.
58+
59+
```ts
60+
const tokens = await mercadolibre.validateAuthorizationCode(code, codeVerifier);
61+
const refreshToken = tokens.refreshToken();
62+
```
63+
64+
Use `refreshAccessToken()` to get a new access token using a refresh token. Mercado Libre returns the same values as during the authorization code validation. This method also returns `OAuth2Tokens` and throws the same errors as `validateAuthorizationCode()`
65+
66+
```ts
67+
import * as arctic from "arctic";
68+
69+
try {
70+
const tokens = await mercadolibre.refreshAccessToken(refreshToken);
71+
const accessToken = tokens.accessToken();
72+
const accessTokenExpiresAt = tokens.accessTokenExpiresAt();
73+
const refreshToken = tokens.refreshToken();
74+
} catch (e) {
75+
if (e instanceof arctic.OAuth2RequestError) {
76+
// Invalid authorization code, credentials, or redirect URI
77+
}
78+
if (e instanceof arctic.ArcticFetchError) {
79+
// Failed to call `fetch()`
80+
}
81+
// Parse error
82+
}
83+
```
84+
85+
## Get user profile
86+
87+
Use the [`/users/me` endpoint](https://developers.mercadolibre.com.ar/es_ar/consulta-usuarios#Consultar-mis-datos-personales).
88+
89+
```ts
90+
const response = await fetch("https://api.mercadolibre.com/users/me", {
91+
headers: {
92+
Authorization: `Bearer ${accessToken}`
93+
}
94+
});
95+
const user = await response.json();
96+
```

0 commit comments

Comments
 (0)