Allow users to get an AccessToken before making Http calls
mraible opened this issue · comments
Matt Raible commented
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.
Matt Raible commented
Consider implementing stormpath/stormpath-sdk-react#175 as part of resolving this issue.