Move redirect uri generation to getRedirectUri function of Connection class.
Use api_endpointPublic instead of cdn_endpointPublic
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Config,
|
||||
ConnectedAccount,
|
||||
ConnectedAccountCommonOAuthTokenResponse,
|
||||
ConnectionCallbackSchema,
|
||||
@@ -41,13 +40,7 @@ export default class BattleNetConnection extends Connection {
|
||||
const url = new URL(this.authorizeUrl);
|
||||
|
||||
url.searchParams.append("client_id", this.settings.clientId!);
|
||||
// TODO: probably shouldn't rely on cdn as this could be different from what we actually want. we should have an api endpoint setting.
|
||||
url.searchParams.append(
|
||||
"redirect_uri",
|
||||
`${
|
||||
Config.get().cdn.endpointPrivate || "http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
);
|
||||
url.searchParams.append("redirect_uri", this.getRedirectUri());
|
||||
url.searchParams.append("scope", this.scopes.join(" "));
|
||||
url.searchParams.append("state", state);
|
||||
url.searchParams.append("response_type", "code");
|
||||
@@ -76,10 +69,7 @@ export default class BattleNetConnection extends Connection {
|
||||
code: code,
|
||||
client_id: this.settings.clientId!,
|
||||
client_secret: this.settings.clientSecret!,
|
||||
redirect_uri: `${
|
||||
Config.get().cdn.endpointPrivate ||
|
||||
"http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
redirect_uri: this.getRedirectUri(),
|
||||
}),
|
||||
)
|
||||
.post()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Config,
|
||||
ConnectedAccount,
|
||||
ConnectedAccountCommonOAuthTokenResponse,
|
||||
ConnectionCallbackSchema,
|
||||
@@ -42,14 +41,7 @@ export default class DiscordConnection extends Connection {
|
||||
url.searchParams.append("response_type", "code");
|
||||
// controls whether, on repeated authorizations, the consent screen is shown
|
||||
url.searchParams.append("consent", "none");
|
||||
|
||||
// TODO: probably shouldn't rely on cdn as this could be different from what we actually want. we should have an api endpoint setting.
|
||||
url.searchParams.append(
|
||||
"redirect_uri",
|
||||
`${
|
||||
Config.get().cdn.endpointPrivate || "http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
);
|
||||
url.searchParams.append("redirect_uri", this.getRedirectUri());
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
@@ -76,10 +68,7 @@ export default class DiscordConnection extends Connection {
|
||||
client_secret: this.settings.clientSecret!,
|
||||
grant_type: "authorization_code",
|
||||
code: code,
|
||||
redirect_uri: `${
|
||||
Config.get().cdn.endpointPrivate ||
|
||||
"http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
redirect_uri: this.getRedirectUri(),
|
||||
}),
|
||||
)
|
||||
.post()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Config,
|
||||
ConnectedAccount,
|
||||
ConnectedAccountCommonOAuthTokenResponse,
|
||||
ConnectionCallbackSchema,
|
||||
@@ -47,13 +46,7 @@ export default class EpicGamesConnection extends Connection {
|
||||
const url = new URL(this.authorizeUrl);
|
||||
|
||||
url.searchParams.append("client_id", this.settings.clientId!);
|
||||
// TODO: probably shouldn't rely on cdn as this could be different from what we actually want. we should have an api endpoint setting.
|
||||
url.searchParams.append(
|
||||
"redirect_uri",
|
||||
`${
|
||||
Config.get().cdn.endpointPrivate || "http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
);
|
||||
url.searchParams.append("redirect_uri", this.getRedirectUri());
|
||||
url.searchParams.append("response_type", "code");
|
||||
url.searchParams.append("scope", this.scopes.join(" "));
|
||||
url.searchParams.append("state", state);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Config,
|
||||
ConnectedAccount,
|
||||
ConnectedAccountCommonOAuthTokenResponse,
|
||||
ConnectionCallbackSchema,
|
||||
@@ -46,13 +45,7 @@ export default class FacebookConnection extends Connection {
|
||||
const url = new URL(this.authorizeUrl);
|
||||
|
||||
url.searchParams.append("client_id", this.settings.clientId!);
|
||||
// TODO: probably shouldn't rely on cdn as this could be different from what we actually want. we should have an api endpoint setting.
|
||||
url.searchParams.append(
|
||||
"redirect_uri",
|
||||
`${
|
||||
Config.get().cdn.endpointPrivate || "http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
);
|
||||
url.searchParams.append("redirect_uri", this.getRedirectUri());
|
||||
url.searchParams.append("state", state);
|
||||
url.searchParams.append("response_type", "code");
|
||||
url.searchParams.append("scope", this.scopes.join(" "));
|
||||
@@ -65,12 +58,7 @@ export default class FacebookConnection extends Connection {
|
||||
url.searchParams.append("client_id", this.settings.clientId!);
|
||||
url.searchParams.append("client_secret", this.settings.clientSecret!);
|
||||
url.searchParams.append("code", code);
|
||||
url.searchParams.append(
|
||||
"redirect_uri",
|
||||
`${
|
||||
Config.get().cdn.endpointPrivate || "http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
);
|
||||
url.searchParams.append("redirect_uri", this.getRedirectUri());
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Config,
|
||||
ConnectedAccount,
|
||||
ConnectedAccountCommonOAuthTokenResponse,
|
||||
ConnectionCallbackSchema,
|
||||
@@ -36,13 +35,7 @@ export default class GitHubConnection extends Connection {
|
||||
const url = new URL(this.authorizeUrl);
|
||||
|
||||
url.searchParams.append("client_id", this.settings.clientId!);
|
||||
// TODO: probably shouldn't rely on cdn as this could be different from what we actually want. we should have an api endpoint setting.
|
||||
url.searchParams.append(
|
||||
"redirect_uri",
|
||||
`${
|
||||
Config.get().cdn.endpointPrivate || "http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
);
|
||||
url.searchParams.append("redirect_uri", this.getRedirectUri());
|
||||
url.searchParams.append("scope", this.scopes.join(" "));
|
||||
url.searchParams.append("state", state);
|
||||
return url.toString();
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Config,
|
||||
ConnectedAccount,
|
||||
ConnectedAccountCommonOAuthTokenResponse,
|
||||
ConnectionCallbackSchema,
|
||||
@@ -48,13 +47,7 @@ export default class RedditConnection extends Connection {
|
||||
const url = new URL(this.authorizeUrl);
|
||||
|
||||
url.searchParams.append("client_id", this.settings.clientId!);
|
||||
// TODO: probably shouldn't rely on cdn as this could be different from what we actually want. we should have an api endpoint setting.
|
||||
url.searchParams.append(
|
||||
"redirect_uri",
|
||||
`${
|
||||
Config.get().cdn.endpointPrivate || "http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
);
|
||||
url.searchParams.append("redirect_uri", this.getRedirectUri());
|
||||
url.searchParams.append("response_type", "code");
|
||||
url.searchParams.append("scope", this.scopes.join(" "));
|
||||
url.searchParams.append("state", state);
|
||||
@@ -85,10 +78,7 @@ export default class RedditConnection extends Connection {
|
||||
new URLSearchParams({
|
||||
grant_type: "authorization_code",
|
||||
code: code,
|
||||
redirect_uri: `${
|
||||
Config.get().cdn.endpointPrivate ||
|
||||
"http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
redirect_uri: this.getRedirectUri(),
|
||||
}),
|
||||
)
|
||||
.post()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Config,
|
||||
ConnectedAccount,
|
||||
ConnectedAccountCommonOAuthTokenResponse,
|
||||
ConnectionCallbackSchema,
|
||||
@@ -57,13 +56,7 @@ export default class SpotifyConnection extends RefreshableConnection {
|
||||
const url = new URL(this.authorizeUrl);
|
||||
|
||||
url.searchParams.append("client_id", this.settings.clientId!);
|
||||
// TODO: probably shouldn't rely on cdn as this could be different from what we actually want. we should have an api endpoint setting.
|
||||
url.searchParams.append(
|
||||
"redirect_uri",
|
||||
`${
|
||||
Config.get().cdn.endpointPrivate || "http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
);
|
||||
url.searchParams.append("redirect_uri", this.getRedirectUri());
|
||||
url.searchParams.append("response_type", "code");
|
||||
url.searchParams.append("scope", this.scopes.join(" "));
|
||||
url.searchParams.append("state", state);
|
||||
@@ -94,10 +87,7 @@ export default class SpotifyConnection extends RefreshableConnection {
|
||||
new URLSearchParams({
|
||||
grant_type: "authorization_code",
|
||||
code: code,
|
||||
redirect_uri: `${
|
||||
Config.get().cdn.endpointPrivate ||
|
||||
"http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
redirect_uri: this.getRedirectUri(),
|
||||
}),
|
||||
)
|
||||
.post()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Config,
|
||||
ConnectedAccount,
|
||||
ConnectedAccountCommonOAuthTokenResponse,
|
||||
ConnectionCallbackSchema,
|
||||
@@ -49,13 +48,7 @@ export default class TwitchConnection extends RefreshableConnection {
|
||||
const url = new URL(this.authorizeUrl);
|
||||
|
||||
url.searchParams.append("client_id", this.settings.clientId!);
|
||||
// TODO: probably shouldn't rely on cdn as this could be different from what we actually want. we should have an api endpoint setting.
|
||||
url.searchParams.append(
|
||||
"redirect_uri",
|
||||
`${
|
||||
Config.get().cdn.endpointPrivate || "http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
);
|
||||
url.searchParams.append("redirect_uri", this.getRedirectUri());
|
||||
url.searchParams.append("response_type", "code");
|
||||
url.searchParams.append("scope", this.scopes.join(" "));
|
||||
url.searchParams.append("state", state);
|
||||
@@ -85,10 +78,7 @@ export default class TwitchConnection extends RefreshableConnection {
|
||||
code: code,
|
||||
client_id: this.settings.clientId!,
|
||||
client_secret: this.settings.clientSecret!,
|
||||
redirect_uri: `${
|
||||
Config.get().cdn.endpointPrivate ||
|
||||
"http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
redirect_uri: this.getRedirectUri(),
|
||||
}),
|
||||
)
|
||||
.post()
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Config,
|
||||
ConnectedAccount,
|
||||
ConnectedAccountCommonOAuthTokenResponse,
|
||||
ConnectionCallbackSchema,
|
||||
@@ -49,13 +48,7 @@ export default class TwitterConnection extends RefreshableConnection {
|
||||
const url = new URL(this.authorizeUrl);
|
||||
|
||||
url.searchParams.append("client_id", this.settings.clientId!);
|
||||
// TODO: probably shouldn't rely on cdn as this could be different from what we actually want. we should have an api endpoint setting.
|
||||
url.searchParams.append(
|
||||
"redirect_uri",
|
||||
`${
|
||||
Config.get().cdn.endpointPrivate || "http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
);
|
||||
url.searchParams.append("redirect_uri", this.getRedirectUri());
|
||||
url.searchParams.append("response_type", "code");
|
||||
url.searchParams.append("scope", this.scopes.join(" "));
|
||||
url.searchParams.append("state", state);
|
||||
@@ -89,10 +82,7 @@ export default class TwitterConnection extends RefreshableConnection {
|
||||
grant_type: "authorization_code",
|
||||
code: code,
|
||||
client_id: this.settings.clientId!,
|
||||
redirect_uri: `${
|
||||
Config.get().cdn.endpointPrivate ||
|
||||
"http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
redirect_uri: this.getRedirectUri(),
|
||||
code_verifier: "challenge", // TODO: properly use PKCE challenge
|
||||
}),
|
||||
)
|
||||
@@ -126,10 +116,7 @@ export default class TwitterConnection extends RefreshableConnection {
|
||||
grant_type: "refresh_token",
|
||||
refresh_token,
|
||||
client_id: this.settings.clientId!,
|
||||
redirect_uri: `${
|
||||
Config.get().cdn.endpointPrivate ||
|
||||
"http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
redirect_uri: this.getRedirectUri(),
|
||||
code_verifier: "challenge", // TODO: properly use PKCE challenge
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Config,
|
||||
ConnectedAccount,
|
||||
ConnectedAccountCommonOAuthTokenResponse,
|
||||
ConnectionCallbackSchema,
|
||||
@@ -56,13 +55,7 @@ export default class XboxConnection extends Connection {
|
||||
const url = new URL(this.authorizeUrl);
|
||||
|
||||
url.searchParams.append("client_id", this.settings.clientId!);
|
||||
// TODO: probably shouldn't rely on cdn as this could be different from what we actually want. we should have an api endpoint setting.
|
||||
url.searchParams.append(
|
||||
"redirect_uri",
|
||||
`${
|
||||
Config.get().cdn.endpointPrivate || "http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
);
|
||||
url.searchParams.append("redirect_uri", this.getRedirectUri());
|
||||
url.searchParams.append("response_type", "code");
|
||||
url.searchParams.append("scope", this.scopes.join(" "));
|
||||
url.searchParams.append("state", state);
|
||||
@@ -121,10 +114,7 @@ export default class XboxConnection extends Connection {
|
||||
grant_type: "authorization_code",
|
||||
code: code,
|
||||
client_id: this.settings.clientId!,
|
||||
redirect_uri: `${
|
||||
Config.get().cdn.endpointPrivate ||
|
||||
"http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
redirect_uri: this.getRedirectUri(),
|
||||
scope: this.scopes.join(" "),
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
Config,
|
||||
ConnectedAccount,
|
||||
ConnectedAccountCommonOAuthTokenResponse,
|
||||
ConnectionCallbackSchema,
|
||||
@@ -56,13 +55,7 @@ export default class YoutubeConnection extends Connection {
|
||||
const url = new URL(this.authorizeUrl);
|
||||
|
||||
url.searchParams.append("client_id", this.settings.clientId!);
|
||||
// TODO: probably shouldn't rely on cdn as this could be different from what we actually want. we should have an api endpoint setting.
|
||||
url.searchParams.append(
|
||||
"redirect_uri",
|
||||
`${
|
||||
Config.get().cdn.endpointPrivate || "http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
);
|
||||
url.searchParams.append("redirect_uri", this.getRedirectUri());
|
||||
url.searchParams.append("response_type", "code");
|
||||
url.searchParams.append("scope", this.scopes.join(" "));
|
||||
url.searchParams.append("state", state);
|
||||
@@ -92,10 +85,7 @@ export default class YoutubeConnection extends Connection {
|
||||
code: code,
|
||||
client_id: this.settings.clientId!,
|
||||
client_secret: this.settings.clientSecret!,
|
||||
redirect_uri: `${
|
||||
Config.get().cdn.endpointPrivate ||
|
||||
"http://localhost:3001"
|
||||
}/connections/${this.id}/callback`,
|
||||
redirect_uri: this.getRedirectUri(),
|
||||
}),
|
||||
)
|
||||
.post()
|
||||
|
||||
Reference in New Issue
Block a user