我已经设置了Angular2,Auth0 facebook登录,我可以登录,获取访问令牌,一切正常。但是当我登录时,允许回调URL无效。它将数据存储在localstorage中并继续加载到同一页面。我已经在auth0客户端下包含了允许的回调网址,并添加了选项。有人解决了这个问题吗?
import { Injectable } from '@angular/core';
import { tokenNotExpired } from 'angular2-jwt';
declare const Auth0Lock: any;
const options = {
auth: {
redirectUrl: 'http://localhost:4200/profile'
}
};
@Injectable()
export class Auth0Service {
lock = new Auth0Lock('<key>', '<url>', options );
constructor() {
this.lock.on('authenticated', (authResult: any) => {
this.lock.getProfile(authResult.idToken, function (error: any, profile: any) {
if (error){
throw new Error(error);
}
localStorage.setItem('id_token', authResult.idToken);
localStorage.setItem('profile', JSON.stringify(profile));
});
});
}