You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example: Django login via username and password requires Authorization: Token abcdef-123456... whereas using the social auth library for logging in via Facebook, Google, et al requires Authorization: Bearer abcdef-123456.... So Token needs to be replaced with Bearer.
Here is a gist using decoration for use in a project, but this can easily be applied as an upgrade to this library.
The key is calling authStorageFactory.set('authType', 'SOME_KEY_TYPE') to map to a key in settings, when you know what login method has been used. Then a different authorization header prefix will be fetched.
(function(angular){'use strict';varmodule=angular.module('login-with-social-auth',['angular-token-auth']);// The objective here is to alter the http config object if the auth type// requires a different AUTH_HEADER_PREFIX.// Somewhere, you need to store the auth type by which the user logged in.// Store it like this:// if (userLoggedInDifferentlyThanNormal) {// authStorageFactory.set('authType', 'SOME_TYPE_KEY');// }// Then hold some settings where you match SOME_TYPE_KEY to an auth header prefix:// "AUTH_HEADER_PREFIXES":// "SOME_TYPE_KEY": "Some prefix string, like Bearer"// }// Note the key is AUTH_HEADER_PREFIXES, not AUTH_HEADER_PREFIX which is// already in use and likely set to `Token` for Django user:pass logins.module.config(['$provide',function($provide){$provide.decorator('authInterceptor',['$delegate','authFactory','authStorageFactory','PROJECT_SETTINGS',function($delegate,authFactory,authStorageFactory,PROJECT_SETTINGS){varoriginalRequest=$delegate.request;$delegate.request=function(){varconfig=originalRequest.apply($delegate,arguments);varauthType=authStorageFactory.get('authType');varauthHeaderPrefixForType=PROJECT_SETTINGS[authType];if(authHeaderPrefixForType){config.headers.Authorization=authHeaderPrefixForType+' '+authFactory.getToken();}returnconfig;};return$delegate;}]);}]);}(window.angular));
The text was updated successfully, but these errors were encountered:
For example: Django login via username and password requires
Authorization: Token abcdef-123456...
whereas using the social auth library for logging in via Facebook, Google, et al requiresAuthorization: Bearer abcdef-123456...
. SoToken
needs to be replaced withBearer
.Here is a gist using decoration for use in a project, but this can easily be applied as an upgrade to this library.
The key is calling
authStorageFactory.set('authType', 'SOME_KEY_TYPE')
to map to a key in settings, when you know what login method has been used. Then a different authorization header prefix will be fetched.The text was updated successfully, but these errors were encountered: