2
votes

I've a microsoft business account and want to store in it uploaded users files. My goal is that the users of my PHP app can manage files, upload files, create folders etc to a oneDrive for business. it can be possible?

I've registered the php app with de microsoft business account and i have the client id and secret.

for example: client_id: 'XXXX'

Now im testing with my personal account. I'm getting an access token using the secret and client id of the business account and I authenticate with my personal microsoft account.

The steps I'm using to authenticated are:

GET https://login.microsoftonline.com/common/oauth2/v2.0/authorize?
state=YYYY
&scope=openid+profile+directory.readwrite.all+files.readwrite.all
&response_type=code
&approval_prompt=auto
&client_id=XXXX
&redirect_uri=http%3A%2F%2Flocalhost%2Ftest

at this point Microsoft prompt a user login form, I authenticated with my personal account.

in the redirect uri I get de code and send a POST request to get the access token.

Now, at this point and with the access token, Can users (in this case me) access to the onedrive for business files/folders...etc? how? Which endpoint I have to use?

for example for accesing the drive:

https://graph.microsoft.com/v1.0/me/drive/root/children

the me parameter is the personal account or the bussiness acount drive?

I'm using this libraries to achieve my goal:

  1. to connect users account to Microsoft Graph Auth2 => https://github.com/microsoftgraph/php-connect-rest-sample

  2. request api resource https://github.com/microsoftgraph/msgraph-sdk-php/wiki/Example-calls

1
@arkascha I dont understand you. its not possible ?José Ramírez
@arkascha do u have any idea?José Ramírez

1 Answers

0
votes

The https://graph.microsoft.com/v1.0/me endpoint will give you details of the signed in user. It should give you information like the Azure object id and the UPN. /drive points to either the personal or the business drive, depending on which account you used during authentication to get the access token. If you make a call to /drive, it will also tell you what type of drive you are querying against. So OneDrive for business will have driveType="business" and OneDrive personal will say driveType="personal". I am glad to see you are using the AAD v2.0 endpoint, since it supports authentication for MSA and AAD. In case you haven't already, you can read more about it here:

https://developer.microsoft.com/en-us/graph/docs/authorization/auth_overview

And specifically for v2.0 authentication, give the following article a try:

https://developer.microsoft.com/en-us/graph/docs/authorization/converged_auth