前提・実現したいこと
現在TodoistというサービスとのAPI認証のプログラムをGASにて作成しています。
GASライブラリで提供されているOAuth2 for Apps Scriptを使用し認証を下記スクリプトの
authorize()を実行したところ、Todoist側認証UR Lへのアクセス、操作許可までは行えるのですが
その後、Google側へ正しく遷移されずエラーが表示されます。
エラーの解決方法や原因等、ご教授お願い致します。
[参考] https://developer.todoist.com/guides/#integration-archetypes
Google側でのエラー表記
Google ドキュメント内でエラーが発生しました。
このページを再読み込みするか、数分後にこのページをもう一度開いてみてください。
該当のソースコード
// 認証を行いアクセストークンをログ出力する function authorize() { const service = getTodoistService(); const authorizationUrl = service.getAuthorizationUrl(); console.log(authorizationUrl); } //Todoistのサービスを取得する関数 function getTodoistService() { //client_id と client_secret はgasの プロパティへ登録済みです const properties = PropertiesService.getScriptProperties(); const clientId = properties.getProperty('client_id'); const clientSecret = properties.getProperty('client_secret'); return OAuth2.createService('Todoist') .setAuthorizationBaseUrl('https://todoist.com/oauth/authorize') .setTokenUrl('https://todoist.com/oauth/access_token') .setClientSecret(clientSecret) .setClientId(clientId) .setScope('data:read') .setCallbackFunction('authCallback') .setPropertyStore(PropertiesService.getUserProperties()) } //認証コールバック関数 function authCallback(request) { const service = getTodoistService(); const isAuthorized = service.handleCallback(request); if (isAuthorized) { return HtmlService.createHtmlOutput('認証成功'); } else { return HtmlService.createHtmlOutput('認証失敗'); }; }
あなたの回答
tips
プレビュー