auth0-samples / auth0-ionic2-samples

MIT License
28 stars 56 forks source link

Changes required when updating to the ionic2 final release #9

Open chanoch opened 7 years ago

chanoch commented 7 years ago

Thanks for the sample application etc. I've been updating it from the release candidate to the final release. A number of changes have resulted from the upgrade to angular 2.2.1. I've tried to tackle the differences but there a couple of questions remaining. I have a working update in my fork but there is a hack in there. 1) I generated a new tabs ionic2 template app

2) In auth.service.ts, I had to change the line:

auth0 = new Auth0({clientID: Auth0Vars.AUTH0_CLIENT_ID, domain: Auth0Vars.AUTH0_DOMAIN });

to:

auth0 = new Auth0.WebAuth({clientID: Auth0Vars.AUTH0_CLIENT_ID, domain: Auth0Vars.AUTH0_DOMAIN });

Prior to this change I was getting the Auth0__default.a is not a constructor problem.

Once this was updated, the rest was fairly simple but I started receiving an error about the device id not being provided in options which was preventing login.

  1. I installed angular-jwt@0.1.28
  2. I renamed main.dev.ts to main.ts as per new convention from ionic
  3. I added a auth.params.device value to fix an error from the login request. This is not recommended so needs review.

I have uploaded my version to my fork if you want to look at the diffs

dan-kez commented 7 years ago

I'm also having issues with auth.params.device. Although the lock screen shows a successful authentication, I get the following error in my authResult:

error
:
"invalid_request"
errorDescription
:
"device parameter must be specified"
state
Kaelink commented 7 years ago

For information, I saw there https://auth0.com/docs/libraries/lock/v10/auth0js that the Auth0.WebAuth() syntax is actually the new one if you are using auth0.js v8.

As for the device not specified, you may try to pass it the params when creating the Auth0Lock (it seems that happen when using 'offline_access' inside scope and running on browser

            params: {
                scope: 'openid offline_access',
                device:'Mobile device'
            },
SindreSB commented 7 years ago

@chanoch I checked out your fork, but i looked like there were several errors in it as well. The refreshToken function is not longer part of the auth0.js, and the project is missing auth0-lock and auth0-js in the project.json.

The device not specified is related to this:

Docs when using refresh tokens(offline_access scope)

To obtain a refresh token, the offline_access scope (see: Scopes) and an arbitrary device name must be included when initiating an authentication request through the authorize endpoint.

saschwarz commented 7 years ago

I've cut a separate issue asking for a workaround for the removal of the refreshToken method: https://github.com/auth0-samples/auth0-ionic2-samples/issues/15