简体   繁体   中英

Trying to figure out auth0 custom login screen callback url

I've been trying to follow this guide to get my custom login screen to work with my angular app locally. The part i'm struggling on is my login callback never gets called.

My original login url is http://localhost:9000/#/login

angular.module('myApp').service('authService', function ($location, angularAuth0) {

    function login(username, password, callback) {
        console.log('in login service');
    angularAuth0.login({
      connection: 'Username-Password-Authentication',
      responseType: 'token',
      email: username,
      password: password
    }, function(err) {
        console.log('we NEVER get here');
    });
  }

    return {
      login: login
    };

});


angular.module('myApp').controller('LoginCtrl', function ($scope, $location, authService) {

    $scope.login = function() {
        ...
        authService.login($scope.user.email, $scope.user.password)

When i login, I get redirected to http://localhost:9000/#/access_token<myaccesstoken>&id_token=<myIdToken>&token_type=Bearer

Why do i get redirected to this url and my callback never get called?

Also when am i supposed to use this function authenticateAndGetProfile() which they create in the guide?

Ok in working with the Auth0 support team, it seems that their documentation was missing this section which has since been added:

Register the authenticateAndGetProfile in app.run.js so that authentication results get processed after login.

// app.run.js

(function () {

  'use strict';

  angular
  .module('app')
  .run(function (authService) {

  // Process the auth token if it exists and fetch the profile
  authService.authenticateAndGetProfile();
  });

})();

That was the missing piece and now everything works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM