LANG SELRCT

Google Apps Scriptのコードを書く場所  (新規作成: スプレッドシート | スクリプトエディタ

2020年1月31日金曜日

Salesforce APIでrevoke tokenを使いたい


OAuth エンドポイントについて に書かれている

OAuth トークンの取り消し: https://login.salesforce.com/services/oauth2/revoke

をGASでやってみます。



コード.gs
function revokeToken() {
  var url = "https://login.salesforce.com/services/oauth2/revoke";
  var options = {
    'method': 'get',
    'contentType': 'application/x-www-form-urlencoded',
    'payload': {
      token: getProp("access_token") // access_tokenをrevokeする場合
      //token: getProp("refresh_token")// refresh_tokenをrevokeする場合
      }
  }
  var response = UrlFetchApp.fetch(url, options);
  Logger.log(response);
}

function getProp(key) {
  return PropertiesService.getScriptProperties().getProperty(key);
}

function setScriptProperties(jobj) {// スクリプトのプロパティに値を保存する
  PropertiesService.getScriptProperties().setProperties(jobj);
}


最新の投稿

JIRA APIで選択リスト(複数選択)を課題作成時に選択してPOSTしたい

JIRA APIを利用して選択リスト(複数選択)フィールドに値を入れたくて書いたコードです。 コード.gsのこの部分で複数選択の値を選択できました。 customfield_10043 は手元のJIRAでの選択リスト(複数選択)のフィールドIDなので、各自の環境によって異なります...