amkirwan / ember-oauth2

JavaScript library for using OAuth 2.0 Implicit Grant flow (Client-Side Flow) with Ember.js
MIT License
133 stars 22 forks source link

Problems doing OAuth2 with HarvestApp. #31

Open jcfergus opened 6 years ago

jcfergus commented 6 years ago

Ok, I've been banging on this most of a day and am not sure how this is supposed to be working. I'm implementing an ember-cli app, and trying to use ember-oauth2 and ember-token-auth to authenticate against Harvest (https://help.getharvest.com/api-v2/authentication-api/authentication/authentication/). (Implicit (client-app) auth flow.) .

I have things working to the point of openWIndow getting called and opening the authentication window, but what seems to be happening is that parseCallback is being called immediately after the dialog is opened, and is getting passed the dialog window and not the locationHash string.

So:

openWindow(url)

returns a promise that is resolved with:

resolve(dialog);

which then is returned from authorize() in ember-oauth2.js:

authorize() {
    return this.openWindow(this.authUri());
}

which is then handled in authorize() in login.js:

sessionCurrent.get('auth').trigger('redirect', response);

That response (the dialog window) is then passed directly into parseCallback() in the handleRedirect function in ember-oauth2.js:

 handleRedirect: Ember.on('redirect', function(hash, callback) {
    let self = this;
    let params = self.parseCallback(hash);

This doesn't seem to be how things are /supposed/ to be working, but I'm not sure if it's something specific to Harvest, or something more general. Halp?