onedrive-api | official middle-level HTTP API bindings | REST library
kandi X-RAY | onedrive-api Summary
kandi X-RAY | onedrive-api Summary
A non-official middle-level HTTP API bindings to the OneDrive REST API through Microsoft Graph
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of onedrive-api
onedrive-api Key Features
onedrive-api Examples and Code Snippets
Community Discussions
Trending Discussions on onedrive-api
QUESTION
I am able to access OneDrive items of all the users in Office 365 business account using a free trial created from this link.
However, in order to make it work I needed to give my application below permission, which eventually allows this app to access OneDrive items of all the users in this tenant because of these permissions.
File.Read.All -> Delegate
File.Read.All -> Application
User.Read -> Delegate
User.Read.All -> Delegate
Site.Read.All -> Delegate
Now, my requirement is to access OneDrive document of only one users from this tenant and block the application from accessing documents from other users, or access document of any personal account (@hotmail.com/@live.com).
Please let me know if there is any way or in case I am doing anything wrong with the application I registered.
Asked the same question here but bot told to ask to azure team in stackoverflow https://github.com/OneDrive/onedrive-api-docs/issues/1219
Appreciate any help.
...ANSWER
Answered 2020-Feb-11 at 06:31Firstly, you need to understand the differences between Application permission and Delegate permission.
Application permission means App-only, the application acts as a user but there is no user sign in.
Delegate permission means App + User, a user will need to log into the application and access the resources.
So based on the permissions you have provided, I can't tell if your application requires a user to log in. If yes, Delegate permissions will take effect. Based on Delegated permissions, Files.Read.All
allows the app to read all files the signed-in user can access. If the signed in user can access others' document, then your app can access them too. So if you control the access permissions for the user in OneDrive or SharePoint, your app with this signed in user will have the same permissions.
If your app doesn't require a signed in user, Application permissions will take effect in this case. Based on Application permissions, Files.Read.All
allows the app to read all files in all site collections without a signed in user. So this scenario does not meet your needs.
QUESTION
I want to create a simple Python utility that interacts with files on OneDrive. Right now I'm using my company account (so I have no access to admin settings or any detailed insight into OneDrive/Sharepoint/Azure configuration).
After quick googling session it seemed that Microsoft Graph is the way to go. I started with copying the sample app and once I verified that basic functionality is working (it shows the name from my profile, etc.) I tried adding a simple call to me/drive/root/children
in order to list files in the root directory. And I am unable to get it working.
No matter what I do, server returns the following:
...ANSWER
Answered 2019-Jul-18 at 09:06After updating the permissions, users and/or admins will have to consent again.You can force user consent through a url request or just click 'grant admin consent button' in azure portal.
https://login.microsoftonline.com/{tenant}/oauth2/authorize? client_id={your_client_id} &response_type=code &response_mode=query &resource=https://graph.microsoft.com &state=12345 &prompt=consent
QUESTION
After a time I finally figure out how to use oAuth2 and how to create a access token with the refresh token. But I can´t find node.js samples for upload files the only thing I found was this module https://www.npmjs.com/package/onedrive-api
But this didn´t work for me because I get this error { error: { code: 'unauthenticated', message: 'Authentication failed' } }
Also if I would enter accessToken: manually with 'xxxxxxx' the result would be the same.
But I created before the upload the access token so I don´t know if this really can be a invalid credits problem. But the funny thing is if I would take the access token from https://dev.onedrive.com/auth/msa_oauth.htm where you can generate a 1h access token the upload function works. I created my auth with the awnser from this question. OneDrive Code Flow Public clients can't send a client secret - Node.js
Also I only used the scope Files.readWrite.all do I maybe need to allow some other scopes ? My code is
ANSWER
Answered 2017-Aug-14 at 01:21How about this sample script? The flow of this sample is as follows.
- Retrieve access token using refresh token.
- Upload a file using access token.
When you use this sample, please import filename, your client id, client secret and refresh token. The detail information is https://dev.onedrive.com/items/upload_put.htm.
Sample script :QUESTION
I try to download several files from OneDrive through Microsoft Graph.
I am very close to achieve my goal. For the moment I have managed the token system (notably through Jay Lee detailed answer), and achieved to resolve the confusion that I made among the different endpoints that exist in Microsoft Graph (thank you Marc LaFleur - MSFT).
Now I really work on the call of the API that would permit to download the files I want. This is how I proceeded:
1- As I've seen in the Microsoft Graph Documentation, the normal syntax would be the following:
curl -w %{time_total} https://graph.microsoft.com/v1.0/me/drive/items/01M...WU/content -H "Authorization: Bearer $access_token"
2- However, this gives me a 302 request, which I can't handle in bash. So I looked for another solution and I found this Microsoft article explaining that:
"To download files from OneDrive in a JavaScript app you cannot use the /content API, since this responds with a 302 redirect. A 302 redirect is explicitly prohibited when a CORS preflight is required, such as when providing the Authorization header.
Instead, your app needs to select the @microsoft.graph.downloadUrl property, which returns the same URL that /content would have redirected to. This URL can then be requested directly using XMLHttpRequest. Because these URLs are pre-authenticated they can be retrieved without a CORS preflight request."
It talks about Javascript but I think it can be applied to my case.
3- So I tried this method and I wrote:
curl "https://graph.microsoft.com/v1.0/me/drive/items/01MB...WU?select=id,@microsoft.graph.downloadUrl" -H "Authorization: Bearer $access_token"
It gave me the URL that normally would permit me to finally download the file, but when I execute it, I get the following response:
Code:
curl "https://graph.microsoft.com/v1.0/$metadata#users('e967dd4d-680e-4a06-9bf7-468875e1a04c')/drive/items/$entity" -H "Authorization: Bearer $access_token"
(it is exactly what I got with the previous request)
Response:
Any help? Why is it a bad request since I've put exactly what I got from the graph.microsoft.com request?
...ANSWER
Answered 2017-May-11 at 03:39https://graph.microsoft.com/v1.0/$metadata#users('e967dd4d-680e-4a06-9bf7-468875e1a04c')/drive/items/$entity
is the @odata.context
annotation, which is not what you're after. You need to pull the URL out of the @microsoft.graph.downloadUrl
annotation and use that to grab the file contents. The URL you're after should mention download.aspx
in it.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install onedrive-api
Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page