Please write your question in detail here.
I am a beginner. I'm sorry if I haven't been able to convey information well because of my lack of knowledge.
Thank you.
Google Apps Script (GAS),
I want to get the token information using Satellite Office Workflow for G Suite public API.

Error message

Error message

Token acquisition processing was performed with UrlFetchApp.fetch, but an acquisition error occurred and the following error message occurred.
An error occurs in the response parameter common to the public API, and the following information is returned.
[18-08-30 18: 43: 32: 163 JST] {"code": 100, "error_code": "invalid_api_key", "error_msg": ""}

### Applicable source code
Google Apps Script (GAS)
Source code

// Get API token
function getToke () {
var apiUrl ='https: //sateraito-apps-workflow.appspot.com/00/api/public/auth&apos ;;

// Request contents
var Request = {
"method":"POST" ;,
"Content-Type" ;:"application/json" ;,
"api_key" ;:"〇〇〇〇〇" ;,
"impersonate_email" ;:"〇〇〇〇〇"

var res = UrlFetchApp.fetch (apiUrl, Request);
txt = res.getContentText ();

Logger.log (txt);



If i rewrite the script several times, only the above error message appears.

Supplemental information (FW/tool version etc.)

Public API information

  • Answer # 1

    You may want to ask directly at the support desk.

    API protocol, interface, URL


    API protocol, interface, URL
      ・ HTTP method is POST (KeyValue type). POST Key and Value for each parameter.
      POST (KeyValue type)

    Because it is

    , you should set it topayload (body)in query string format.

    UrlFetchApp # fetch

    1, 2, GAS does not implement the URLSearchParams interface, so create a function to create a QueryString (query string).

    function QueryString (dict) {
      var keys = [];
      for (var k in dict) {
        keys.push (k + '=' + encodeURI (dict [k]));
      return keys.join ("&");
    function getToken () {// getToke → getToken
      var apiUrl = 'https://sateraito-apps-workflow.appspot.com/00/api/public/auth';
      var params = {
        "api_key": "XXXXX",
        "impersonate_email": "[email protected]"
      var Request = {
        "method": "POST",
        'payload': QueryString (params)
      var res = UrlFetchApp.fetch (apiUrl, Request);
      txt = res.getContentText ();
      Logger.log (txt);

Related articles