Add Twitch, error handling, revokation changes, etc
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
ApiError,
|
||||
Config,
|
||||
ConnectedAccount,
|
||||
ConnectedAccountCommonOAuthTokenResponse,
|
||||
@@ -70,12 +71,18 @@ export default class GitHubConnection extends Connection {
|
||||
Accept: "application/json",
|
||||
},
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
if (!res.ok) {
|
||||
throw new ApiError("Failed to exchange code", 0, 400);
|
||||
}
|
||||
|
||||
return res.json();
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(
|
||||
`Error exchanging token for ${this.id} connection: ${e}`,
|
||||
`Error exchanging code for ${this.id} connection: ${e}`,
|
||||
);
|
||||
throw DiscordApiErrors.INVALID_OAUTH_TOKEN;
|
||||
throw DiscordApiErrors.GENERAL_ERROR;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -86,7 +93,20 @@ export default class GitHubConnection extends Connection {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}).then((res) => res.json());
|
||||
})
|
||||
.then((res) => {
|
||||
if (!res.ok) {
|
||||
throw new ApiError("Failed to fetch user", 0, 400);
|
||||
}
|
||||
|
||||
return res.json();
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(
|
||||
`Error fetching user for ${this.id} connection: ${e}`,
|
||||
);
|
||||
throw DiscordApiErrors.GENERAL_ERROR;
|
||||
});
|
||||
}
|
||||
|
||||
async handleCallback(
|
||||
|
||||
Reference in New Issue
Block a user