Notice: important security update for Drive document URLs and resource keys. For more information, refer to Access link-shared files using resource keys

Display the sharing dialog

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.

Share button and dialog
Figure 1. Share button and 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:

<script type="text/javascript" src=""></script>
<script type="text/javascript">
    init = function() {
        s = new;
    window.onload = function() {
        gapi.load('drive-share', init);


Add a launch button

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.