Keycloakとのやり取りにKeycloak.jsを使用していて、エラーが発生しています
Uncaught Error: [$injector:unpr] Unknown provider: AuthProvider <- Auth <- authInterceptor <- $http <- $templateRequest <- $compile
以下のコードで:
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');
}]);
これが起こっている理由はありますか?
Bowerで挿入されたindex.htmlにkeycloak.jsも含めています
また、dom 内でインスタンス化された以下の Auth ファクトリを用意しています。
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();
});
});