This is a login package using twitch for meteor. It lets users on your website login with their twitch account by adding a single button (provided by the packlage).
cd <your-meteor-project>
meteor add service-configuration
meteor add alexbeauchemin:accounts-twitch
-
Register your app with Twitch Developer Site at following url- http://www.twitch.tv/kraken/oauth2/clients/new
-
Fill out the given form but make sure that redirect url as shown as follows-
OAuth redirect_uri:<your-server-domain>:<port>/_oauth/twitch?close
For e.g.redirect url for localhost : http://localhost:3000/_oauth/twitch?close
-
After registration, note down the client id and client secret.
-
In your app, create the
accounts.js
, put following code inside<your-app-directory>/server/accounts.js
with your client id and client secretServiceConfiguration.configurations.remove({ service: "twitch" }); ServiceConfiguration.configurations.insert({ service: "twitch", clientId: "<your-client-id>", redirectUri: Meteor.absoluteUrl() + '_oauth/twitch?close', secret: "<your-client-secret>" });
-
Add the default twitch login button by adding this in your page
{{>twitchLoginButton}}
or add this code on the click event of your custom button
Meteor.loginWithTwitch(function (err) {
if (err) console.log('login failed: ' + err)
});
if you want specific permissions, add the scope as an option
var scope = ['user_read', 'user_blocks_read', 'user_subscriptions'];
Meteor.loginWithTwitch({requestPermissions: scope}, function (err) {
if (err) console.log('login failed: ' + err)
});
Now you should be able to create and account and login with Twitch