0
kaustubh.kale@ness.com created
ABP Framework version: v4.3.1 UI type: Angular DB provider: EF Core Tiered (MVC) or Identity Server Separated (Angular): no / yes Exception message and stack trace: N.A Steps to reproduce the issue:" N.A
We want to add HttpHeader in Login method call . how we can add one more httpHeader in below request .Currently We paasing Username and Password .
We are using Angular 11 for client side . Please find below implementation of login method.
constructor(private authService: AuthService)
var loginParams = {
username: this.form.get('username').value,
password: this.form.get('password').value
}
this.authService
.login(loginParams)
.pipe(
catchError((err) => {
return err;
}),
finalize(() => (this.inProgress = false))
)
.subscribe(() => {
var tokeParams = {
fullToken: this.oauthService.getAccessToken()
}
});
});
}
3 Answer(s)
-
0
Hi Team any update on above?
-
0
Hi,
You can use a method like below:
login(params: LoginParams): Observable<any> { const router = this.injector.get(Router); const tenant = this.sessionState.getTenant(); return from( this.oAuthService.fetchTokenUsingPasswordFlow( params.username, params.password, new HttpHeaders({ ...(tenant && tenant.id && { __tenant: tenant.id }) }), // add headers here ), ).pipe( switchMap(() => this.appConfigService.get()), tap(res => { this.configState.setState(res); this.setRememberMe(params.rememberMe); if (params.redirectUrl) router.navigate([params.redirectUrl]); }), ); }
Resource: https://github.com/abpframework/abp/blob/73723bfa26b6709fbf908145df8aece8d25fe5bf/npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts#L190-L208