New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set up the prompt = 'select_account' #2769
Comments
@ismail1971 You can find our When you call an API such as loginPopup({
scopes: ["User.Read"],
prompt: "select_account"
}); |
I have the code like this and using :
} export function MSALGuardConfigFactory(): MsalGuardConfiguration { |
this.authService.loginRedirect({
...this.msalGuardConfig.authRequest,
prompt: "select_account"
}); |
@tnorling Sorry, it's not prompting for login selection rather use the last logged-in user and signed it with it. I am using the code sample microsoft-authentication-library-for-js/samples/msal-angular-v2-samples/angular10-sample-app/ |
@tnorling |
@ismail1971 Can you share the steps you took that resulted in receiving that error? |
The prompt set works fine from the login function as you suggested, but if I have MsalGuard to a route, { path: 'profile', component: ProfileComponent, canActivate: [ MsalGuard ]} will auto sign in without the prompt. Is there a way to set the prompt at the time of configuring the MSALGuardConfigFactory() in app.module.ts: export function MSALGuardConfigFactory(): MsalGuardConfiguration {
return { interactionType: InteractionType.Redirect };
} @tnorling, I am investigating my code for the error. Maybe I have a bug. |
@tnorling I also try to create a AuthGuard like this: import { Component, OnInit, Inject, OnDestroy, Injectable } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Route, UrlSegment} from '@angular/router';
import { Observable } from 'rxjs';
import { MsalService, MSAL_GUARD_CONFIG, MsalGuardConfiguration } from '@azure/msal-angular';
@Injectable({
providedIn: 'root',
})
export class AuthGuard implements CanActivate {
constructor(
private authService: MsalService,
@Inject(MSAL_GUARD_CONFIG) private msalGuardConfig: MsalGuardConfiguration,
) {}
canActivate( next: ActivatedRouteSnapshot, state: RouterStateSnapshot ): | Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
return this.checkLoggedIn();
}
canLoad(route: Route, segments: UrlSegment[]): boolean {
return this.checkLoggedIn();
}
checkLoggedIn(): boolean {
if (this.authService.instance.getAllAccounts().length > 0) { return true; }
else{ this.authService.loginRedirect({...this.msalGuardConfig.authRequest, prompt: "select_account"}); }
return false;
}
} And the following routes will give the error I have mentioned earlier : const routes: Routes = [
{ path: 'profile', component: ProfileComponent, canActivate: [ AuthGuard ] },
{ path: 'code', component: HomeComponent, canActivate: [ AuthGuard ] },
{ path: '', component: HomeComponent, canActivate: [ AuthGuard ] }
]; Thanks for your help. |
@ismail1971 You can include a request object on the export function MSALGuardConfigFactory(): MsalGuardConfiguration {
return { interactionType: InteractionType.Redirect,
authRequest: {prompt: "select_account"}
};
} |
This issue has not seen activity in 14 days. It will be closed in 7 days if it remains stale. |
After adding the authRequest: {prompt: "select_account"} I am getting complie error. Error: src/app/app.module.ts:64:12 - error TS2322: Type '{ prompt: string; }' is not assignable to type 'PopupRequest | Pick<RedirectRequest, "prompt" | "state" | "scopes" | "authority" | "correlationId" | "claims" | "resourceRequestMethod" | "resourceRequestUri" | ... 9 more ... | "onRedirectNavigate">'. 64 authRequest: {prompt: "select_account"} node_modules/@azure/msal-browser/dist/src/request/RedirectRequest.d.ts:27:5 |
@ismail1971 Can you include a scopes parameter on your request? Alternatively you can add |
@tnorling @jasonnutter Do you have a newer version of the msal-angular? I have "@azure/msal-angular": "^2.0.0-alpha.1". Thanks |
@ismail1971 Not yet, the change to not require scopes was just merged and has not been released. |
@jasonnutter Thanks. // @ts-ignore works. |
This issue has not seen activity in 14 days. It will be closed in 7 days if it remains stale. |
Library
msal@1.x.x
or@azure/msal@1.x.x
@azure/msal-browser@2.x.x
@azure/msal-node@1.x.x
@azure/msal-react@1.x.x
@azure/msal-angular@0.x.x
@azure/msal-angular@1.x.x
@azure/msal-angular@2.x.x
@azure/msal-angularjs@1.x.x
Description
Would you please let me know how to configure the prompt = 'select_account' in msal 2.0
Source
The text was updated successfully, but these errors were encountered: