Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth Headers not added, using localStorage and sending API request via Angular service #252

Closed
noahmatisoff opened this issue Jan 26, 2016 · 1 comment

Comments

@noahmatisoff
Copy link

I have set up ng-token-auth and after authenticating the auth info is not being attached to subsequent requests:

$authProvider.configure({
    apiUrl: 'https://myapi.com/api/v1',
    tokenValidationPath: '/auth/sign_in',
    validateOnPageLoad: true,
  tokenFormat: {
    "access-token": "{{ token }}",
    "token-type":   "Bearer",
    "client":       "{{ clientId }}",
    "expiry":       "{{ expiry }}",
    "uid":          "{{ uid }}"
  },
  handleTokenValidationResponse: function(response) {
    console.log(response);
  }
});

The above snippet is defined inside of my Angular module's config function. I'm making the HTTP request to my API in an Angular controller, using either a service or using $httpProvider, ex:

$http.get('https://myapi.com/api/v1/me')
  .then(function(response) {
    //authorized users only response
  });

Why is ng-token-auth not attaching the data listed in tokenFormat? The data is stored in localStorage, but not being attached to HTTP requests sent in my Angular app.

@noahmatisoff
Copy link
Author

Didn't specify storage: 'localStorage'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant