To allow users to share Drive files directly from your app, you can use the
Google Drive sharing dialog. This modal dialog is invoked
from your app to allow sharing of items on Drive. Figure 1 shows the Google Docs
Share button and the resulting sharing dialog.
To enable the Drive sharing dialog, add the dialog script and a launch button
or other launching mechanism to your UI.
Add the dialog script
To create an instance of the sharing dialog, add the following script to your
launching page:
<head>
...
<script type="text/javascript" src="https://apis.google.com/js/api.js"></script>
<script type="text/javascript">
init = function() {
s = new gapi.drive.share.ShareClient();
s.setOAuthToken('<OAUTH_TOKEN>');
s.setItemIds(['<FILE_ID>']);
}
window.onload = function() {
gapi.load('drive-share', init);
}
</script>
</head>
Where:
In your UI, add a line of code similar to the following:
<button onclick="s.showSettingsDialog()">Share</button>
This code calls the
showSettingsDialog()
function when the Share button is
clicked.