Can not login with auth0 lock

Clash Royale CLAN TAG#URR8PPPCan not login with auth0 lock
I use auth0 to create function login with angularjs.
When I input email and password login success not return message and redirect to login page again.
I check data return cannot see 'id_token'.
app.js include config auth
auth.service.js
(function () {
'use strict';
angular.module('BlurAdmin')
.service('authService', authService);
authService.$inject = ['lock', '$location'];
function authService(lock, $location) {
function login() {
// Display the Lock widget using the
// instance initialized in the app.js config
lock.show();
}
function logout() {
// Remove tokens and expiry time from localStorage
localStorage.removeItem('access_token');
localStorage.removeItem('id_token');
localStorage.removeItem('expires_at');
$location.path('/');
}
function handleAuthentication() {
// Uncomment if you are not using HTML5Mode
// lock.interceptHash();
lock.on('authenticated', function(authResult) {
if (authResult && authResult.accessToken && authResult.idToken) {
console.log('Authenticated!', authResult);
_setSession(authResult);
}
});
lock.on('authorization_error', function(err) {
console.log(err);
alert(
'Error: ' + err.error + '. Check the console for further details.'
);
});
}
function _setSession(authResult) {
// Set the time that the Access Token will expire
var expiresAt = JSON.stringify(
authResult.expiresIn * 1000 + new Date().getTime()
);
// Save tokens and expiration to localStorage
localStorage.setItem('access_token', authResult.accessToken);
localStorage.setItem('id_token', authResult.idToken);
localStorage.setItem('expires_at', expiresAt);
}
function isAuthenticated() {
// Check whether the current time is
// past the Access Token's expiry time
var expiresAt = JSON.parse(localStorage.getItem('expires_at'));
return new Date().getTime() < expiresAt;
}
return {
login: login,
logout: logout,
handleAuthentication: handleAuthentication,
isAuthenticated: isAuthenticated
};
}
})();
1 Answer
1
at first glance you are probably not receiving an id_token because you have not specified in your app.js the responseType to contain id_token:
id_token
app.js
responseType
id_token
auth: {
...
responseType: 'token id_token',
...
}
give that a try and you should be good to go!
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.