mirror of
https://github.com/Dan6erbond/sk-auth.git
synced 2025-10-08 11:14:18 +02:00
38 lines
965 B
JavaScript
38 lines
965 B
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
var providers_oauth2 = require('./oauth2.js');
|
|
require('../helpers.js');
|
|
require('./oauth2.base.js');
|
|
require('./base.js');
|
|
|
|
const defaultConfig = {
|
|
id: "github",
|
|
scope: "user",
|
|
accessTokenUrl: "https://github.com/login/oauth/access_token",
|
|
authorizationUrl: "https://github.com/login/oauth/authorize",
|
|
profileUrl: "https://api.github.com/user",
|
|
headers: {
|
|
Accept: "application/json"
|
|
}
|
|
};
|
|
class GitHubOAuth2Provider extends providers_oauth2.OAuth2Provider {
|
|
constructor(config) {
|
|
super({
|
|
...defaultConfig,
|
|
...config
|
|
});
|
|
}
|
|
async getUserProfile(tokens) {
|
|
const tokenType = "token";
|
|
const res = await fetch(this.config.profileUrl, {
|
|
headers: { Authorization: `${tokenType} ${tokens.access_token}` }
|
|
});
|
|
return await res.json();
|
|
}
|
|
}
|
|
|
|
exports.GitHubOAuth2Provider = GitHubOAuth2Provider;
|
|
//# sourceMappingURL=github.js.map
|