nativescript-oauth
nativescript-oauth copied to clipboard
Already Logged in
trafficstars
if you are already logged into facebook using device browser of facebook application my application asks me to log in
i think it should use my existing token
Hi @ScriptiZer .. What I did in my app was to verify if the token is still valid, if it was then I would go to my main screen, if not I would refresh the token or ask for a new login.. Something like this:
if (tnsOAuthModule.instance.tokenResult) {
console.log('Accesss token expires at: ' + tnsOAuthModule.instance.tokenResult.accessTokenExpiration);
if (tnsOAuthModule.accessTokenExpired() === true) {
tnsOAuthModule.instance.refreshToken()
.then((result: string) => {
console.log('SUCCESSFULLY REFRESHED TOKEN!');
console.log(result);
this.login();
})
.catch((er) => {
console.log(er);
this.ensureToken();
});
} else{
this.login();
}
}
else{
this.ensureToken();
}