keycloak php,Keycloak未知提供者错误

伍捷
2023-12-01

我使用Keycloak.js与Keycloak进行交互并获取低于错误的信息

Uncaught Error: [$injector:unpr] Unknown provider: AuthProvider

module.factory('authInterceptor', ['$q', 'Auth', function($q, Auth) {

return {

request: function (config) {

var deferred = $q.defer();

if (Auth.authz.token) {

Auth.authz.updateToken(5).success(function() {

config.headers = config.headers || {};

config.headers.Authorization = 'Bearer ' + Auth.authz.token;

deferred.resolve(config);

}).error(function() {

deferred.reject('Failed to refresh token');

});

}

return deferred.promise;

}

};

}]);

module.config(['$httpProvider', function($httpProvider) {

$httpProvider.responseInterceptors.push('errorInterceptor');

$httpProvider.interceptors.push('authInterceptor');

}]);这是为什么发生这种情况的原因吗?

我也在我的index.html中包含了keycloak.js,它是与Bower一起插入的

我也有下面的Auth工厂在dom内部实例化:

angular.element(document).ready(function($http) {

var keycloakAuth = new Keycloak('keycloak.json');

auth.loggedIn = false;

keycloakAuth.init().success(function () {

auth.loggedIn = true;

auth.authz = keycloakAuth;

auth.logoutUrl = keycloakAuth.authServerUrl + "/realms/demo/tokens/logout?redirect_uri=http://localhost:3000";

module.factory('Auth', function () {

return auth;

});

}).error(function () {

window.location.reload();

});

});

 类似资料: