Skip to content

mahi889/angular-11-jwt-refresh-token

 
 

Repository files navigation

Angular 11 JWT Refresh Token example with Http Interceptor

You can take a look at following flow to have an overview of Requests and Responses that Angular 11 Client will make or receive.

Angular JWT Refresh Token Flow

angular-11-refresh-token-jwt-interceptor-example

For more detail, please visit:

Angular 11 JWT Refresh Token example with Http Interceptor

Angular 11 JWT Authentication & Authorization with Web API

Fullstack

Angular + Spring Boot: JWT Authentication & Authorization example

Angular + Node.js Express: JWT Authentication & Authorization example

Open app/_helpers/auth.interceptor.js, modify the code to work with x-access-token like this:

...

// const TOKEN_HEADER_KEY = 'Authorization'; // for Spring Boot back-end
const TOKEN_HEADER_KEY = 'x-access-token';   // for Node.js Express back-end

@Injectable()
export class AuthInterceptor implements HttpInterceptor {
  ...

  private addTokenHeader(request: HttpRequest<any>, token: string) {
    /* for Spring Boot back-end */
    // return request.clone({ headers: request.headers.set(TOKEN_HEADER_KEY, 'Bearer ' + token) });

    /* for Node.js Express back-end */
    return request.clone({ headers: request.headers.set(TOKEN_HEADER_KEY, token) });
  }
}

...

Run ng serve --port 8081 for a dev server. Navigate to http://localhost:8081/.

More practice

Angular 11 CRUD Application example with Web API

Angular 11 Pagination example using ngx-pagination

Angular 11 File Upload example with progress bar

Fullstack with Node.js Express:

Angular 11 + Node.js Express + MySQL

Angular 11 + Node.js Express + PostgreSQL

Angular 11 + Node.js Express + MongoDB

Angular 11 + Node.js Express: JWT Authentication & Authorization example

Fullstack with Spring Boot:

Angular 11 + Spring Boot + MySQL

Angular 11 + Spring Boot + PostgreSQL

Angular 11 + Spring Boot + MongoDB

Angular 11 + Spring Boot: File upload example

Angular 11 + Spring Boot: JWT Authentication & Authorization example

Fullstack with Django:

Angular 11 + Django Rest Framework

Angular 11 + Django + MySQL

Angular 11 + Django + PostgreSQL

Serverless with Firebase:

Angular 11 Firebase CRUD Realtime DB | AngularFireDatabase

Angular 11 Firestore CRUD | AngularFireStore

Angular 11 Upload File to Firebase Storage example

Integration (run back-end & front-end on same server/port)

How to Integrate Angular with Node.js Restful Services

How to Integrate Angular with Spring Boot Rest API

About

Angular 11 JWT Refresh Token before Expiration with Http Interceptor example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 72.2%
  • HTML 18.6%
  • JavaScript 5.8%
  • CSS 3.4%