MrSwitch / hello.js

A Javascript RESTFUL API library for connecting with OAuth2 services, such as Google+ API, Facebook Graph and Windows Live Connect
https://adodson.com/hello.js/
MIT License
4.63k stars 549 forks source link

Cannot read property 'response_type' of undefined #465

Open terebentina opened 7 years ago

terebentina commented 7 years ago

I am getting this error when using the vimeo module. The error happens on https://github.com/MrSwitch/hello.js/blob/master/dist/hello.all.js#L404 I have google, facebook, twitter, instagram and vimeo set up and all but vimeo work just fine. My hellojs setup is like this:

hello.init({
  facebook: process.env.FACEBOOK_APP_ID,
  instagram: process.env.INSTAGRAM_APP_ID,
  google: process.env.GOOGLE_APP_ID,
  twitter: process.env.TWITTER_APP_ID,
  vimeo: process.env.VIMEO_APP_ID,
}, {
  response_type: 'code',
  force: false,
  display: 'popup',
});

and then calling individual logins for modules like

    hello('vimeo').login({ redirect_uri: redirectUri, state: { userId: this.props.userId }});

Basically the problem is that provider.oauth is undefined so provider.oauth.response_type throws. opts.response_type is defined (to code as per init).

Is there something I am doing wrong or this is a bug? I load hellojs from npm.

terebentina commented 7 years ago

Oh, I noticed that vimeo is not built into hello.all.js. I suspect this is the actual problem, right?

MrSwitch commented 7 years ago

Yup 'all' is semantically wrong, shall change it to 'recommended' one day.

terebentina commented 7 years ago

Any way currently of loading vimeo on top of all with npm? And a more general question: are you willing to switch to commonjs? I need vimeo and if there's currently no way of loading it with npm I will end up forking hellojs and making it work so I could as well PR you back. The way I see it, all the bundles should still work the same, from browser, from browserify, etc.

MrSwitch commented 7 years ago

@terebentina

So can you try ...

const hello = require('hello/dist/hello.all.js');
window.hello = hello;
require('hello/src/modules/vimeo.js');

Yes working on hello-es6 branch using commonjs, but no timeline as yet.