Reputation: 1
im trying to access my onedrive from an azure ML script , both using same account ( though the azure one is personal while the onedrive one is work ) . The connection succeeds but then gives a 400 error...any idea why ? thanks ---------------- Authenticated! Client Error: 400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/drive/root | Error Message: Tenant does not have a SPO license.
--------------
from O365 import Account
credentials = ('client id xxxx 6fb8a4', 'secret value xxxxx v6Hyoa2K')
account = Account(credentials,auth_flow_type='credentials',tenant_id='87xxxxx8-3db7f7',main_resource='[email protected]')
storage = account.storage()
if account.authenticate():
print('Authenticated!')
my_drive = storage.get_default_drive()
root_folder = my_drive.get_root_folder()
# iterate over the first 25 items on the root folder
for item in root_folder.get_items(limit=25):
if item.is_folder:
print(list(item.get_items(2))) # print the first two element on this folder.
Upvotes: 0
Views: 203
Reputation: 10455
Client Error: 400 Client Error: Bad Request for url: https://graph.microsoft.com/v1.0/drive/root | Error Message: Tenant does not have a SPO license.
The error you are getting for that you need to notice the couple of things. Please check the points stated in this stackover flow reference which says,
Office 365, Azure Active Directory, EMS (Enterprise Mobility Suite), personal Outlook, personal OneDrive, and other Microsoft cloud services
are all accessible through the developer portal or API known as Microsoft Graph. The API is free to use, but in order to access the data it hides, you must have those services, some of which may be free and others of which you may have to pay for.Regarding integrating Office 365 into your current tenant. I believe you used a Microsoft Account to join up for Azure. For that tenant, you can still buy or acquire Office 365. You may have to add a new Azure AD user to your tenant (not a Microsoft Account) and give them company admin privileges. Whether it asks if you already have a tenant or account, login in with the AAD account you just generated. You should then be able to sign up for Office 365. And there you have it an Azure AD tenant with both an Azure AND an Office 365 subscription.
Solution : You must be using an Office 365 Home license for you azure ad tenant. For SharePoint Online you need an Office 365 Business account .
You need a license that include all the OneDrive service (Operation). So, recommendation is Office 365 Business Essentials which is the cheapest and has Microsoft Graph functionality - more than just upload/manipulate Excel files in OneDrive in future.
So from the above conclusion, you can't use the Microsoft Graph API to access OneDrive data(read and upload) without having SharePoint Online (which only comes with the business licenses).
Reference:
Upvotes: 0