Skip to content
Advertisement

How we can share a google docs link with others without requesting access using PHP?

Is it possible to share a google docs link to others so that they can see and edit my google docs without requesting access. I already gone through this link https://developers.google.com/drive/api/v3/reference/files for “webView link”. But I am not getting it how to use it in my code using PHP so that I can share my google docs without requesting access.

This is my code-

JavaScript

I have also used the proper scopes and after changing the scopes i have also deleted the token.json file and again authenticated the user.

Then also I am unable to execute how to share a google docs with others using PHP so that they can see my docs without requesting access.

Through the above mentioned code I am able to create a doc file and insert text in it properly but now i want to share it with others.What else I have to do to achieve this. Please help me out with this query.

for help and documentation i was following this link https://developers.google.com/drive/api/v2/manage-sharing and inserted my code at the same as–

JavaScript

it’s giving this error-

JavaScript

Advertisement

Answer

You need to use the Permissions: create method of the Google Drive API to create a new Permission with the parameters you require.

Make a Permissions: create request to the Drive API with the ID of the file you wish to set the permission on will set up the permission.

With the file ID you can make the request along with a request body which contains the permission type:

Example cURL Request:

JavaScript

The data '{"role":"editor","type":"user","emailAddress":"user@example.com"}' line sets the permissions so that the user with email address user@example.com has edit permissions for the file. You can read more about the Permissions resource here

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement