GithubHelp home page GithubHelp logo

meteor-accounts-twitch's Introduction

Meteor Acccounts Twitch

Twitch account login for meteor

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).

Install

cd <your-meteor-project>

meteor add service-configuration

meteor add alexbeauchemin:accounts-twitch

Setup and Usage

  1. Register your app with Twitch Developer Site at following url- http://www.twitch.tv/kraken/oauth2/clients/new

  2. 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

  1. After registration, note down the client id and client secret.

  2. In your app, create the accounts.js, put following code inside <your-app-directory>/server/accounts.js with your client id and client secret

    ServiceConfiguration.configurations.remove({
      service: "twitch"
    });
    ServiceConfiguration.configurations.insert({
      service: "twitch",
      clientId: "<your-client-id>",
      redirectUri: Meteor.absoluteUrl() + '_oauth/twitch?close',
      secret: "<your-client-secret>"
    });
    
  3. 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

meteor-accounts-twitch's People

Contributors

alexbeauchemin avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

meteor-accounts-twitch's Issues

Meteor.user() filled right after login, empty after reloading page.

Hi there!

Thanks for making this awesome package! I'm having a little issue trying to implement it though.
When I click on the button and authorize my Twitch App it seems to all go just fine. When the popup closes both Meteor.user() and Meteor.userId() are filled and it seems a user is authenticated.

When I refresh the page however; Meteor.user() is undefined.

I'm unsure what I'm doing wrong here.

What also doesn't seem to be working is the following router hook (iron-router):

Router.onBeforeAction(function () {
    // if the user is not logged in, redirect to Login template
    if (!Meteor.userId())
    {
        Router.go('login');
        this.next();
    }
    // otherwise don't hold up the rest of hooks or our route/action function
    // from running
    else
    {
        this.next();
    }
});

This however works for all other login methods. I'm using Meteor 1.3.4.1, maybe the package isn't compatible I don't know.

Please let me know if I need to supply more data to get this resolved :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.