2017-05-25 3 views
1

にGoogleのファイルピッカーを使用しました。私はPicker APIをセットアップするのに苦労しています。Google Appsのスクリプトは - 私は彼らのドライブからフォルダを選択し、ユーザを必要とするアプリケーションを作成していスタンドアロンスクリプト

Following this documentation私は彼らの「Hello Worldの」スクリプトを使用して私のプロジェクトを設定したが「devlopedKey」と「クライアントID」を変更した後、私はエラーを受信するためのコードをテスト:

エラー401、invalid_client、無登録の原点を。

周りに検索した後、私はhttp://localhost:8888に、クライアントの資格認定の範囲内のJavaScriptの原点を設定するための提案を発見しました。これを実行した後、私は別のエラーが表示されます。これは私の単純なミスである場合

エラー400、origin_mismatch

申し訳ありませんが、任意の助けいただければ幸いです。

答えて

1

Googleがスクリプトをアプリ用に特別にsetOriginしなければなりません。ここで

var picker = new google.picker.PickerBuilder() 
      // Instruct Picker to display only spreadsheets in Drive. For other 
      // views, see https://developers.google.com/picker/docs/#otherviews 
      .addView(google.picker.ViewId.SPREADSHEETS) 
      // Hide the navigation panel so that Picker fills more of the dialog. 
      .enableFeature(google.picker.Feature.NAV_HIDDEN) 
      // Hide the title bar since an Apps Script dialog already has a title. 
      .hideTitleBar() 
      .setOAuthToken(token) 
      .setDeveloperKey(DEVELOPER_KEY) 
      .setCallback(pickerCallback) 
//THIS IS THE IMPORTANT LINE FOR YOU 
      .setOrigin(google.script.host.origin) 
      // Instruct Picker to fill the dialog, minus 2 pixels for the border. 
      .setSize(DIALOG_DIMENSIONS.width - 2, 
       DIALOG_DIMENSIONS.height - 2) 
      .build(); 
     picker.setVisible(true); 

はドキュメントです:https://developers.google.com/apps-script/guides/dialogs#file-open_dialogs

関連する問題