diff --git a/backends/dropbox/index.js b/backends/dropbox/index.js index 58f5c92..f316ee6 100644 --- a/backends/dropbox/index.js +++ b/backends/dropbox/index.js @@ -68,10 +68,6 @@ export default class Dropbox extends OAuthBackend { }); } - oAuthParams () { - return `&redirect_uri=${encodeURIComponent(this.constructor.authProvider)}&response_type=code`; - } - static userCall = ["users/get_current_account", "null", "POST"]; static userSchema = { username: "email", diff --git a/backends/github/github.js b/backends/github/github.js index 57353d0..cfc8c8d 100644 --- a/backends/github/github.js +++ b/backends/github/github.js @@ -11,8 +11,8 @@ export default class Github extends OAuthBackend { this.updatePermissions({ read: true }); } - oAuthParams () { - return "&scope=user%20repo"; + static get oAuthParams () { + return super.oAuthParams + "&scope=user%20repo"; } static userSchema = { diff --git a/backends/google/google.js b/backends/google/google.js index f170656..781d5e8 100644 --- a/backends/google/google.js +++ b/backends/google/google.js @@ -18,8 +18,8 @@ export default class Google extends OAuthBackend { avatar: ["picture", "photoURL"], }; - oAuthParams () { - return `&redirect_uri=${this.constructor.authProvider}&response_type=code&scope=${encodeURIComponent(this.constructor.scopes.join(" "))}`; + static get oAuthParams () { + return super.oAuthParams + `&scope=${ encodeURIComponent(this.scopes.join(" ")) }`; } static oAuth = "https://accounts.google.com/o/oauth2/auth"; diff --git a/src/oauth-backend.js b/src/oauth-backend.js index 55b2929..e9bd5fd 100644 --- a/src/oauth-backend.js +++ b/src/oauth-backend.js @@ -56,8 +56,8 @@ export default class OAuthBackend extends AuthBackend { } // Any extra params to be passed to the oAuth URL. - oAuthParams () { - return ""; + static get oAuthParams () { + return `&redirect_uri=${ encodeURIComponent(this.authProvider) }&response_type=code`; } /** @@ -238,7 +238,7 @@ export default class OAuthBackend extends AuthBackend { backend: oAuthBackend.name }; - this.authPopup = open(`${this.constructor.oAuth}?client_id=${this.clientId}&state=${encodeURIComponent(JSON.stringify(state))}` + this.oAuthParams(), + this.authPopup = open(`${this.constructor.oAuth}?client_id=${this.clientId}&state=${encodeURIComponent(JSON.stringify(state))}` + this.constructor.oAuthParams, "popup", `width=${popup.width},height=${popup.height},left=${popup.left},top=${popup.top}`); if (!this.authPopup) {