@@ -13,7 +13,7 @@ export class Foo {
13
13
14
14
@Injectable ( )
15
15
export class AppService {
16
- public clientId = 'newClient ' ;
16
+ public clientId = 'jwtClient ' ;
17
17
public redirectUri = 'http://localhost:8084/' ;
18
18
19
19
constructor (
@@ -23,10 +23,11 @@ export class AppService {
23
23
let params = new URLSearchParams ( ) ;
24
24
params . append ( 'grant_type' , 'authorization_code' ) ;
25
25
params . append ( 'client_id' , this . clientId ) ;
26
+ params . append ( 'client_secret' , 'jwtClientSecret' ) ;
26
27
params . append ( 'redirect_uri' , this . redirectUri ) ;
27
28
params . append ( 'code' , code ) ;
28
29
29
- let headers = new HttpHeaders ( { 'Content-type' : 'application/x-www-form-urlencoded; charset=utf-8' } ) ;
30
+ let headers = new HttpHeaders ( { 'Content-type' : 'application/x-www-form-urlencoded; charset=utf-8' , 'Authorization' : 'Basic ' + btoa ( this . clientId + ":secret" ) } ) ;
30
31
this . _http . post ( 'http://localhost:8083/auth/realms/baeldung/protocol/openid-connect/token' , params . toString ( ) , { headers : headers } )
31
32
. subscribe (
32
33
data => this . saveToken ( data ) ,
@@ -39,7 +40,7 @@ export class AppService {
39
40
Cookie . set ( "access_token" , token . access_token , expireDate ) ;
40
41
Cookie . set ( "id_token" , token . id_token , expireDate ) ;
41
42
console . log ( 'Obtained Access token' ) ;
42
- window . location . href = 'http://localhost:8089 ' ;
43
+ window . location . href = 'http://localhost:8084 ' ;
43
44
}
44
45
45
46
getResource ( resourceUrl ) : Observable < any > {
0 commit comments