2

I have an ionic 3 application where I want to use the touchId feature.

The backend API is being developed in .net.

For my authentication model, I'm thinking that after a user enters a login name and password and is authenticated by the server, it sends back a JWT token.

I can store the token locally and then every time a user uses the touchId it checks if a token is stored locally, then matches that token to the server and that will allow access.

Is this how it works?

1 Answer 1

5

you can use angular2-jwt, it works perfectly and send your token automatically with all your http requests and you can manage your token expiration very easy

you can only give the source of your access token in your config file from ionic storage, here is the config for ionic:

import { JwtModule, JWT_OPTIONS } from '@auth0/angular-jwt';
import { Storage } from '@ionic/storage';

export function jwtOptionsFactory(storage) {
return {
  tokenGetter: () => {
   return storage.get('access_token');
 }
}
}


@NgModule({

imports: [
 JwtModule.forRoot({
    jwtOptionsProvider: {
    provide: JWT_OPTIONS,
    useFactory: jwtOptionsFactory,
    deps: [Storage]
  }
})
]})
Sign up to request clarification or add additional context in comments.

1 Comment

Hi Fateh, thanks!. Will this work with .net core on the back end?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.