react native jwt token authentication on login
up vote
0
down vote
favorite
Within my form component I am using a placeholder for my jwt token.
export const ACCESS_TOKEN = 'access_token';
In my login function(within form component) I have returned the jwt token to the log
const token = response.data.token;
console.log("token is: ", token);
I then have an authorization helper as shown
import AsyncStorage from 'react-native';
import ACCESS_TOKEN from './components/Form';
export const onSignIn = async () => AsyncStorage.setItem(ACCESS_TOKEN, 'true');
export const onSignOut = () => AsyncStorage.removeItem(ACCESS_TOKEN);
export const isSignedIn = () =>
new Promise((resolve, reject) =>
AsyncStorage.getItem(ACCESS_TOKEN)
.then(res =>
if (res !== null)
resolve(true);
else
resolve(false);
)
.catch(err => reject(err));
);
//
My question is how do I pass my jwt token that is returned from log in to my authorization helper, instead of using placeholder one.
Any help is appreciated.
Thanks
reactjs react-native authentication login jwt
add a comment |
up vote
0
down vote
favorite
Within my form component I am using a placeholder for my jwt token.
export const ACCESS_TOKEN = 'access_token';
In my login function(within form component) I have returned the jwt token to the log
const token = response.data.token;
console.log("token is: ", token);
I then have an authorization helper as shown
import AsyncStorage from 'react-native';
import ACCESS_TOKEN from './components/Form';
export const onSignIn = async () => AsyncStorage.setItem(ACCESS_TOKEN, 'true');
export const onSignOut = () => AsyncStorage.removeItem(ACCESS_TOKEN);
export const isSignedIn = () =>
new Promise((resolve, reject) =>
AsyncStorage.getItem(ACCESS_TOKEN)
.then(res =>
if (res !== null)
resolve(true);
else
resolve(false);
)
.catch(err => reject(err));
);
//
My question is how do I pass my jwt token that is returned from log in to my authorization helper, instead of using placeholder one.
Any help is appreciated.
Thanks
reactjs react-native authentication login jwt
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Within my form component I am using a placeholder for my jwt token.
export const ACCESS_TOKEN = 'access_token';
In my login function(within form component) I have returned the jwt token to the log
const token = response.data.token;
console.log("token is: ", token);
I then have an authorization helper as shown
import AsyncStorage from 'react-native';
import ACCESS_TOKEN from './components/Form';
export const onSignIn = async () => AsyncStorage.setItem(ACCESS_TOKEN, 'true');
export const onSignOut = () => AsyncStorage.removeItem(ACCESS_TOKEN);
export const isSignedIn = () =>
new Promise((resolve, reject) =>
AsyncStorage.getItem(ACCESS_TOKEN)
.then(res =>
if (res !== null)
resolve(true);
else
resolve(false);
)
.catch(err => reject(err));
);
//
My question is how do I pass my jwt token that is returned from log in to my authorization helper, instead of using placeholder one.
Any help is appreciated.
Thanks
reactjs react-native authentication login jwt
Within my form component I am using a placeholder for my jwt token.
export const ACCESS_TOKEN = 'access_token';
In my login function(within form component) I have returned the jwt token to the log
const token = response.data.token;
console.log("token is: ", token);
I then have an authorization helper as shown
import AsyncStorage from 'react-native';
import ACCESS_TOKEN from './components/Form';
export const onSignIn = async () => AsyncStorage.setItem(ACCESS_TOKEN, 'true');
export const onSignOut = () => AsyncStorage.removeItem(ACCESS_TOKEN);
export const isSignedIn = () =>
new Promise((resolve, reject) =>
AsyncStorage.getItem(ACCESS_TOKEN)
.then(res =>
if (res !== null)
resolve(true);
else
resolve(false);
)
.catch(err => reject(err));
);
//
My question is how do I pass my jwt token that is returned from log in to my authorization helper, instead of using placeholder one.
Any help is appreciated.
Thanks
reactjs react-native authentication login jwt
reactjs react-native authentication login jwt
asked Nov 10 at 17:03
OscLiam
11
11
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241300%2freact-native-jwt-token-authentication-on-login%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown