auth0-ionic2-samples icon indicating copy to clipboard operation
auth0-ionic2-samples copied to clipboard

Changes required when updating to the ionic2 final release

Open chanoch opened this issue 7 years ago • 4 comments

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 [email protected]
  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

chanoch avatar Jan 26 '17 00:01 chanoch

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

dan-kez avatar Jan 30 '17 03:01 dan-kez

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'
            },

Kaelink avatar Feb 14 '17 06:02 Kaelink

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

SindreSB avatar Feb 16 '17 10:02 SindreSB

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

saschwarz avatar Mar 31 '17 13:03 saschwarz