Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Twitch API oAuth & profile #418

Merged
merged 1 commit into from Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/providers/twitch.js
Expand Up @@ -2,24 +2,24 @@

const internals = {};


/* https://dev.twitch.tv/docs/authentication/#introduction */
exports = module.exports = function (options) {

return {
protocol: 'oauth2',
useParamsAuth: true,
auth: 'https://api.twitch.tv/kraken/oauth2/authorize',
token: 'https://api.twitch.tv/kraken/oauth2/token',
scope: ['user_read'],
auth: 'https://id.twitch.tv/oauth2/authorize',
token: 'https://id.twitch.tv/oauth2/token',
scope: ['user:read:email'],
scopeSeparator: ' ',
profile: async function (credentials, params, get) {

const queryOptions = {
oauth_token: params.access_token
};

const profile = await get('https://api.twitch.tv/kraken/user', queryOptions);
credentials.profile = profile;
/*
https://dev.twitch.tv/docs/api/reference/#get-users
Passing no args to the request gives authenticated user details
*/
const queryOptions = {};
const profileResponse = await get('https://api.twitch.tv/helix/users', queryOptions);
credentials.profile = profileResponse.data[0];
}
};
};
2 changes: 1 addition & 1 deletion test/providers/twitch.js
Expand Up @@ -34,7 +34,7 @@ describe('twitch', () => {
email: 'kappa@example.com'
};

Mock.override('https://api.twitch.tv/kraken/user', profile);
Mock.override('https://api.twitch.tv/helix/users', { data: [profile] });

server.auth.strategy('custom', 'bell', {
password: 'cookie_encryption_password_secure',
Expand Down