question

BhoomeshJoshi-1641 avatar image
0 Votes"
BhoomeshJoshi-1641 asked MichaelHan-MSFT commented

How to make Graph API calls from Angular http://localhost:4200 port?

Hello Everyone,

I have created one project in Angular. I need to GET/POST data from the SharePoint list.

I have created Microsoft Graph API App to achieve the same.

When I tried to GET/POST data in SharePoint list using Postman. It is working correctly.

But when I integrate that code in Angular and run that project on localhost throws me the below error.

"Access to XMLHttpRequest at 'https://login.microsoftonline.com/{ {directoryId}}/oauth2/v2.0/token' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."




office-sharepoint-onlinemicrosoft-graph-data-connect
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered MichaelHan-MSFT commented

Hi @BhoomeshJoshi-1641,

You could integrate the Microsoft Authentication Library for Angular into the application to obtain the necessary OAuth access token to call the Microsoft Graph

Please refer to this article to use Microsoft Graph in Angular app: https://docs.microsoft.com/en-us/graph/tutorials/angular?tutorial-step=3



If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@BhoomeshJoshi-1641,

Is there anything update? Have you tried the solution I provided?

0 Votes 0 ·