Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Allow users to get an AccessToken before making Http calls #43

Open
mraible opened this issue Jan 11, 2017 · 1 comment
Open

Allow users to get an AccessToken before making Http calls #43

mraible opened this issue Jan 11, 2017 · 1 comment

Comments

@mraible
Copy link
Contributor

mraible commented Jan 11, 2017

From the AngularJS implementation:

// This access token getter attempts to refresh expired access tokens if needed, which is why it is async (promise)

$auth.getAccessToken()
  .then(function(accessToken){
    $http({
      url: 'http://localhost:3000/api/subscription',
      method: 'GET',
      headers: {
        Authorization: 'Bearer ' + accessToken
      }
    );
  })
  .catch(function(){
    // Could not get access token, user is not logged in
  });

If access token is expired, it will automatically try to get a new one with a refresh token.

@mraible
Copy link
Contributor Author

mraible commented Feb 1, 2017

Consider implementing stormpath/stormpath-sdk-react#175 as part of resolving this issue.

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

No branches or pull requests

1 participant