I have a bot framework application which able to call Graph API. There is an oauth authentication flow to login my user to bot application. I can query Graph API like following requests:
https://graph.microsoft.com/v1.0/me
https://graph.microsoft.com/v1.0/sites/xxxx.sharepoint.com:/sites/test:/lists/Test/items
I want to query SharePoint Online API with the same token that used to call Graph API. I gave necessary permissions in AAD application where located in Azure Portal. I wrote below code but I got a 401 Not Authorized
exception from SPO API. How can I call SPO API with the same token?
ClientContext context = TokenHelper.GetClientContextWithAccessToken("https://mytenant.sharepoint.com/sites/test/", _token);
SharePoint.Client.List testList = context.Web.Lists.GetByTitle("Test");
CamlQuery query = CamlQuery.CreateAllItemsQuery(100);
ListItemCollection items = testList.GetItems(query);
context.Load(items);
context.ExecuteQuery(); //Fires 401 error