This repository has been archived by the owner on Oct 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Another 404 #17
Comments
@MonizDave thank you very much for catching this! I'll fix the link asap. About your issue, can you share your Angular SPA configuration file? (i.e. To call this API, it should look like this: @NgModule({
declarations: [
AppComponent,
ProfileComponent,
HomeComponent
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
HttpClientModule,
MatToolbarModule,
MatButtonModule,
MatListModule,
AppRoutingModule,
MsalModule.forRoot({
auth: {
clientId: 'SPA_CLIENT_ID',
authority: 'https://login.microsoftonline.com/YOUR_TENANT_ID',
redirectUri: 'http://localhost:4200',
},
cache: {
cacheLocation: 'localStorage',
storeAuthStateInCookie: isIE, // set to true for IE 11
},
},
{
popUp: !isIE,
consentScopes: [
'user.read',
'openid',
'profile',
'api://API_CLIENT_ID/access_as_user'
],
unprotectedResources: [],
protectedResourceMap: [
['http://localhost:5000/api', ['api://API_CLIENT_ID/access_as_user']]
],
extraQueryParameters: {}
})
],
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: MsalInterceptor,
multi: true
}
],
bootstrap: [AppComponent]
})
export class AppModule { } Then, your const API_ENDPOINT = 'https://graph.microsoft.com/v1.0/me';
@Component({
selector: 'app-profile',
templateUrl: './profile.component.html',
styleUrls: ['./profile.component.css']
})
export class ProfileComponent implements OnInit {
profile;
constructor(private authService: MsalService, private http: HttpClient) { }
ngOnInit() {
this.getProfile();
}
getProfile() {
this.http.get(API_ENDPOINT)
.subscribe({
next: (profile) => {
this.profile = profile;
},
error: (err: AuthError) => {
// If there is an interaction required error,
// call one of the interactive methods and then make the request again.
if (InteractionRequiredAuthError.isInteractionRequiredError(err.errorCode)) {
this.authService.acquireTokenPopup({
scopes: this.authService.getScopesForEndpoint(API_ENDPOINT)
})
.then(() => {
this.http.get(API_ENDPOINT)
.toPromise()
.then(profile => {
this.profile = profile;
});
});
}
}
});
}
} |
Thank you! This level of detail should be added to the instructions. |
Will work on that, thanks @MonizDave |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: