Skip to content

Commit

Permalink
New Twitch API oAuth & profile
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-checkpoint committed Jul 29, 2019
1 parent c129f4c commit b632b95
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
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

0 comments on commit b632b95

Please sign in to comment.