Skip to Main Content
Spring Boot 2.0 Projects
book

Spring Boot 2.0 Projects

by Mohamed Shazin Sadakath
July 2018
Intermediate to advanced content levelIntermediate to advanced
336 pages
9h 23m
English
Packt Publishing
Content preview from Spring Boot 2.0 Projects

Using an Angular service for OAuth2 authentication and authorization

OAuth2-based security is enabled in the backend API now. Angular can be modified to include code to generate and retrieve an access_token, use it to access protected resource endpoints. For this particular reason, an AuthService like the following one is used:

import {Injectable} from '@angular/core';import {Router} from '@angular/router';import { Cookie } from 'ng2-cookies';import { Http, Response, Headers, RequestOptions } from '@angular/http';import { Observable } from 'rxjs/Observable';import 'rxjs/add/operator/catch';import 'rxjs/add/operator/map';@Injectable()export class AuthService {  constructor(    private router: Router, private http: Http){} getAndSaveAccessToken(loginData){ ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Spring Boot 2.0

Mastering Spring Boot 2.0

Dinesh Rajput
Mockito for Spring

Mockito for Spring

Sujoy Acharya

Publisher Resources

ISBN: 9781789136159Supplemental Content