Move redirect uri generation to getRedirectUri function of Connection class.

Use api_endpointPublic instead of cdn_endpointPublic
This commit is contained in:
Madeline
2023-03-18 19:33:32 -04:00
committed by Puyodead1
parent 9d5c5a8292
commit c7277efbad
15 changed files with 45 additions and 138 deletions
+3 -16
View File
@@ -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
}),
)