Apps Scriptリファレンス: Apps Script Reference |障害・課題追跡: IssueTracker |Google Workspace: Status Dashboard - Summary

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);
}


Latest post

スプレッドシートの空白セルを直前の値で埋めたい

A列の空白セルに直前の値を入れたくて書いたコードです スプレッドシートに以下のようなBeforeの表があるとき (A列に空白セルがある) Before 1 A B 2 エリア 都市 3 東京 新宿 4 渋谷 5 池袋 6 神奈川 横浜 7 川崎 8 相模原 9 千葉 千葉 10 ...