mirror of
https://github.com/Dan6erbond/sk-auth.git
synced 2025-08-03 13:48:09 +02:00
🏷️ Remove comments / use OAuth2ProviderConfig
for GoogleOAuth2Provider
types
This commit is contained in:
parent
b19192a0c8
commit
93af8f2a0a
@ -1,8 +1,6 @@
|
||||
import { OAuth2Provider, OAuth2ProviderConfig } from "./oauth2";
|
||||
|
||||
interface GoogleOAuth2ProviderConfig extends OAuth2ProviderConfig {}
|
||||
|
||||
const defaultConfig: Partial<GoogleOAuth2ProviderConfig> = {
|
||||
const defaultConfig: Partial<OAuth2ProviderConfig> = {
|
||||
id: "google",
|
||||
scope: ["openid", "profile", "email"],
|
||||
accessTokenUrl: "https://accounts.google.com/o/oauth2/token",
|
||||
@ -10,44 +8,11 @@ const defaultConfig: Partial<GoogleOAuth2ProviderConfig> = {
|
||||
profileUrl: "https://openidconnect.googleapis.com/v1/userinfo",
|
||||
};
|
||||
|
||||
export class GoogleOAuth2Provider extends OAuth2Provider<GoogleOAuth2ProviderConfig> {
|
||||
constructor(config: GoogleOAuth2ProviderConfig) {
|
||||
export class GoogleOAuth2Provider extends OAuth2Provider {
|
||||
constructor(config: OAuth2ProviderConfig) {
|
||||
super({
|
||||
...defaultConfig,
|
||||
...config,
|
||||
});
|
||||
}
|
||||
|
||||
/* getAuthorizationUrl({ host }: ServerRequest, auth: Auth, state: string) {
|
||||
const data = {
|
||||
response_type: "code",
|
||||
client_id: this.config.clientId,
|
||||
scope: Array.isArray(this.config.scope) ? this.config.scope.join(" ") : this.config.scope,
|
||||
redirect_uri: this.getCallbackUri(auth, host),
|
||||
state,
|
||||
};
|
||||
|
||||
const url = `${this.config.authorizationUrl!}?${new URLSearchParams(data)}`;
|
||||
return url;
|
||||
} */
|
||||
|
||||
/* async getTokens(code: string, redirectUri: string) {
|
||||
const data = {
|
||||
code,
|
||||
client_id: this.config.clientId,
|
||||
client_secret: this.config.clientSecret,
|
||||
redirect_uri: redirectUri,
|
||||
grant_type: "authorization_code",
|
||||
};
|
||||
|
||||
const res = await fetch(this.config.accessTokenUrl!, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
|
||||
return await res.json();
|
||||
} */
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user