I have not tried the Microsoft graph api yet but i'm just wondering if we can use the same accesstoken for both onedrive api and microsoft graph api.
Also, is there any method from onedrive that is not available in the graph api ?
Thanks,
Phuong
+1
There is one access token.
New MS Graph API works with OneDrive, OneDrive for business, office 365
All this works with a single access token. You only need to set correct scopes when getting a token
The access tokens are different between calling Microsoft Graph (https://graph.microsoft.com), OneDrive Personal (https://api.onedrive.com) and OneDrive for Business or SharePoint (https://tenant-my.sharepoint.com). The advantage about using Microsoft Graph is that you only need a single token for all the API capabilities that are available as Microsoft Graph.
However, if you have already written code for OneDrive API (and are calling OneDrive's direct endpoint) you would need to request a new access token for Microsoft Graph, and request the required permissions for using Microsoft Graph.
It seems it is not true. I already have the code working fine. Using a single endpoint it works fine for onedrive personal, onedrive for business and sharepoint sites.
One token works for onedrive business and sharepoint sites for same live account
There are all docs
https://dev.onedrive.com/getting-started.htm
for share point you have to use /sites/ calls . under sites there are drives and then you ork with drives with same way as onedrive drives
I think the question was: "if we get a token from msgraph with a onedrive scope, can we use the same token to call the onedrive rest endpoint"
As an example I have already an app which used the onedrive rest endpoint. Now I want to migrate over to msgraph because it supports also SharePoint. But then I realize that not all of onedrive api I need is supported. So I could have a mix of calls to msgraph and onedrive. Do I need different tokens for both endpoints?
I think the answer is no because these are two different endpoint but it would be cool because this would support migration scenarios.
From my understanding according to the conversation, if we have a graph api access token, it can be used for onedrive end point as well. But if we have one drive access token, it can't be used for other end point.
Each API end point needs a token for that endpoint. You can't use the same access_token for Microsoft Graph and OneDrive API. You can however use the same refresh_token (and thus the same login session) to generate tokens for different endpoints. So you can have an application that makes calls to both OneDrive and Microsoft Graph, but only asks the user to sign-in once.
This is one of the big advantages to using Microsoft Graph, is that a single token provides access to a variety of data sources across Microsoft services.
@barisbikmaz I'm interested in knowing which APIs you use with OneDrive that aren't available in MS Graph, since our goal is that there is full parity between the two API surfaces.
Our problem is currently not OneDrive more the SharePoint REST Api. We want to migrate to MSGraph API but the MSGraph SharePoint API is currently more focused on files and folders and not list items. Therefore we thought if its possible to use the same token for both endpoints we could migrate parts of our application and our customers don't need to grant consent again, because we have to change the scopes when migrating to MsGraph.
Got it, thanks @barisbikmaz. You can actually accomplish what you want, by requesting permissions for both Microsoft Graph and Office 365 SharePoint in the AAD portal for your application registration. You can then have a single consent flow for (new) users (you would need to use prompt=consent for existing users to re-request consent for the additional scopes). Once the user has gone through the consent process and consented to all the scopes your app would require, you can use the /token endpoint to request a token for Graph or for SharePoint directly.