Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4830

Unable to access emberOauth2 as a service

$
0
0

@em.b wrote:

I'm using the ember-oauth2 library v2.0.2-beta, having installed it using the command: npm install --save-dev ember-oauth2

I have configured my config/environment.js file as follows, per the suggestion at the site referenced above:

    EmberENV: {
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      },
      EXTEND_PROTOTYPES: {
        // Prevent Ember Data from overriding Date.parse.
        Date: false
      },
      'ember-oauth2': {
        slack: {
          clientId: "28957355378.299482941425",
          authBaseUri: 'https://slack.com/oauth/authorize',
          redirectUri: 'https://localhost:4200/app/search',
          scope: 'public write'
        }
      }

I have configured a login route that displays the 'Sign in with Slack' button.

I have configured routes/login.js as follows, per the suggestions at the aforementioned site:

import Ember from 'ember';

export default Ember.Route.extend({
  emberOauth2: Ember.inject.service(),

  actions: {
    authenticate(providerId) {
      debugger;
      emberOauth2.setProvider(providerId);
      return emberOauth2.authorize().then(function(response) {
        debugger;
        emberOauth2.get('auth').trigger('redirect', response.location.hash);
      }, function(error) {
        debugger;
        emberOauth2.get('auth').trigger('error', error);
      });
    }
  }
});

But when I fire up my server I get the following errors:

routes/login.js: line 9, col 7, 'emberOauth2' is not defined.
routes/login.js: line 10, col 14, 'emberOauth2' is not defined.
routes/login.js: line 12, col 9, 'emberOauth2' is not defined.
routes/login.js: line 15, col 9, 'emberOauth2' is not defined.

And when I hit my first debug statement in the login route, sure enough, there is no such object emberOauth2.

Please help.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4830

Trending Articles