I prefer iOS (Objective-C) code but the question is linked with google drive API. So a solution in any other programming language may belong here.
My previous code:
GTLQueryDrive *query = [GTLQueryDrive queryForFilesList];
query.q = ...;
... //send query and get links to files
But it was correct in Google Drive API v2 only - query returned a list of GTLDriveFile objects and GTLDriveFile contained field downloadUrl.
But Google Drive API v3 doesn't have such field and according to this document I should perform additional request with queryForFilesGetWithFileId: and link 2 results between themselves, shouldn't I? How to solve this issue?
downloadUrl has been removed. If you want download file, i have tried successfully!
How to download pdf from google drive V3 API in IOS?
Referring to Download Files, you'll use one of the given URLs below, depending on the type of download that you'd like to perform.
Download a file — files.get with alt=media file resource
Download and export a Google Doc — files.export
Link a user to a file — webContentLink from the file resource
For example, to download a file using alt=media, you make an authorized HTTP GET request to the file's resource URL and include the query parameter alt=media. Using the sample request format:
GET https://www.googleapis.com/drive/v3/files/0B9jNhSvVjoIVM3dKcGRKRmVIOVU?alt=media
Authorization: Bearer ya29.AHESVbXTUv5mHMo3RYfmS1YJonjzzdTOFZwvyOAUVhrs
As stated, your app must be authorized with a scope that allows reading of file content. And, an app using the drive.readonly.metadata scope would not be authorized to download the file contents. Users with edit permission may restrict downloading by read-only users by setting the viewersCanCopyContent field to true.
Please check through the documentation for the detailed instructions for performing the given types of downloads.
Related
I am trying to upload a large (> 4mb) attachment to an existing message in Office 365. I am following these instructions: https://learn.microsoft.com/en-us/graph/outlook-large-attachments?tabs=http
I have successfully created the upload session, and obtained a uploadUrl value that looks legitimate, it roughly matches the example in the documentation. Then I start my PUT to this url, for the first byte range that I've selected. I'm sure I'm setting the Content-Type, Content-Length and Contact-Range headers correctly. My problem is that I get http 401 (Unauthorized) in response. The error header returned is "The audience claim value is invalid for current resource..." and it regurgitates my url and it looks intact.
My theory is that I need to add another API permission to my application. I already have mail read.write, and that allows me to create a < 4mb attachment. If I need another permission, which one? Or do I have some other problem?
According to this documentation page on Resumable Uploads, you'll need any of Files.ReadWrite, Files.ReadWrite.All or Sites.ReadWrite.All permissions for a Delegated Work account.
If you're using an Application token, then you need Sites.ReadWrite.All permission.
What were the permissions you were missing that you had to add out of interest? Was the docs clear from our perspective? I can see the Resumable file upload permissions is specific to SharePoint and can use "Files.ReadWrite, Files.ReadWrite.All, Sites.ReadWrite.All".
For mail message you'd need Mail.ReadWrite as per this doc for large file upload https://learn.microsoft.com/en-us/graph/api/message-post-attachments?view=graph-rest-1.0&tabs=http
I've created a feedback item on the doc to get this updated. https://github.com/microsoftgraph/microsoft-graph-docs/issues/6817
I download a Google Doc file in Json format (application/vnd.google-apps.document) from Google using documents.get.
How do I upload this file back to Google Drive? The description for documents.create method clearly says that it can create only a blank document:
Creates a blank document using the title given in the request. Other
fields in the request, including any provided content, are ignored.
Are there any other method to upload application/vnd.google-apps.document (in native Google format, not docx)?
Note that unlike documents.create, spreadsheets.create method allows uploading file content and works just fine.
I am unable to upload a file using a valid access token (the token allows me to list groups, drive items etc.). The error that appears is:
invalidRequest: One of the provided arguments is not acceptable.
Using the following PUT request:
https://graph.microsoft.com/v1.0/groups/{my group id}/drive/items/{my item(folder) id}:/test.txt:/content
using content type: text/plain
I tested this exact same request using the graph explorer https://developer.microsoft.com/en-us/graph/graph-explorer and my office 365 user account and the upload worked, so I though it might be an app permissions thing, however this did not work even after granting absolutely every permission to the app and regenerating the access tokem.
Please help as I would rather use an access token than my user account to perform the uploads.
Thankyou
Oliver
Just add a worked endpoint on my side:
PUT https://graph.microsoft.com/v1.0/groups/my-group-id/drive/root:/test.txt:/content
Request body: The contents of the file goes here.
The content type of request header does not need to be configured.
You need to check your folder path too.
I managed to resolve by creating a new app definition in Azure AD with the same permissions and it worked! Perhaps there was some corruption in my original Azure application - maybe the manifest was corrupt (due to a bug)?
When querying the Graph with the PHP library for a given drive I receive 400 Unable to retrieve user's mysite URL or 429 Too many requests.
When I call for example https://graph.microsoft.com/v1.0/users/b0633c25-2655-4dfe-a2b2-078e4310deba/drive with the PHP library it gives this weird result. When I query the same url in the Graph Explorer. It works like a charm.
I've set up the permissions as described in the docs and have the E3 Developers subscription that is still valid.
What am I missing?
The error message is misleading and does not mention billing as it should.
Check your Billing > Your Products (subscription) in your Microsoft 365 Admin and then try again.
The best way to test is:
https://developer.microsoft.com/en-us/graph/graph-explorer
The current error seems like user does not have ODFB(OneDrive For Business) site created, you can check if the user have create OneDrive site(the OneDrive site will be created while the user first time to use it).
To debug that issue for now, try to use Graph Explorer https://developer.microsoft.com/en-us/graph/graph-explorer# and login with your user account.
If you can access /me then try accessing /me/drive/root and you will get details about ODFB Doc Lib for current user if it exist.
we can get results with the following link for login-in user
https://graph.microsoft.com/v1.0/me/drive/root/children
Reference for you: https://github.com/microsoftgraph/microsoft-graph-docs/issues/1354
I have an image saved in my Firebase Storage. I would like to display this image in multiple emails that I send. I have so far used the download URL as obtained from my Firebase console and the image displays successfully. My question is: Is this the correct way of sharing the image? Is it secure? If not, then how should I get a secure link to that image?
Here's where I got the download URL from, in the Firebase console:
Any help on this would be appreciated.
Using a download URL is the appropriate way to share files outside of an application, or to users who don't need to be logged in.
I'm curious what you mean by "is it secure"? If you're sharing the object with someone, they can forward the link to someone else who can download it, but they can also just download the object and share it as well.
If you want to control access based on a particular user, you'll need to have users log in and download the objects in an application, rather than using download URLs. Granted, again, here they can take the downloaded object and share it with anyone else.