I am trying to use the Graph API, I am authenticating against a SharePoint site as the resource URL. This is because I am using C# CSOM api to talk with the sharepoint site.
When I try and make a graph api request with the same bearer token it says unauthorised. I have given the mobile app the permissions for Graph API too. Does this mean that my resource uri needs to be different, if so what should it be as its not clear? I am unsure how to find it.
I basically want to give the registered app in azure permission to sharepoint and graph api. When I get the token, I want to be able to use this for both types of requests
var client = new HttpClient();
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "TOKEN_FROM_AUTHENTCIATION");
var result = client.GetAsync("https://graph.microsoft.com/v1.0/me/messages?$select=subject,from,receivedDateTime&$top=25&$orderby=receivedDateTime%20DESC").Result;
My connection details are similar to the following:
<add key="ida:AADInstance" value="https://login.microsoftonline.com/{0}" />
<add key="ida:Tenant" value="mytenant.onmicrosoft.com" />
<add key="ida:ApplicationId" value="A GUID" />
<add key="ida:RedirectUri" value="http://AnyUri/" />
<add key="ida.ResourceUrl" value="https://mytenant.sharepoint.com/" />
I am thinking that my ResourceUrl need to be a graph api one but unable understand what it should be, Do I have to create an instance of the graph api for my domain?
I am making this request with the token using fiddler as follows, but this comes back as unauthorised 401
GET https://graph.windows.net/22312560-20c8-0000-0000-0000000000/users/[email protected]/$links/manager?api-version=1.6
Content-Type: text/json
Accept: application/json
Host: graph.windows.net
Content-Length: 0
Authorization: Bearer <THE_TOKEN>