OneDrive - Unauthorized 400 is being written for Microsoft Graph API using credentials auth flow

Copper Contributor



I'm working on a POC for one of my customer, here are few details.


Firstly, I'm setting up a sample app in app registrations section at with below details

-> client secret

-> API permissions - only User.Read just to read User Info

-> Redirect URI for Web with a value http://localhost:8080 


Now, I'm unable to authenticate with below endpoint{tenant}oauth2/v2.0/token
body - grant_type = password, client_id, username, password, client secret, scope =


Now, for this request, I'm getting Unauthorized - 401 exception.


Exception in thread "main" java.lang.Error: Error reading authorization response: Server returned HTTP response code: 400 for URL: tenant id/oauth2/v2.0/token


Can someone help me What I'm missing with?


I just need a solution to be such that my client does NOT require to login or does anything to authenticate and download files from OneDrive. I use Linux, so we don't want to handle anything so everything including authentication should be automated. Is there a way?


Thanks in advance!





0 Replies