LANG SELRCT

Apps Script Reference  (Create: Create new Spreadsheet | Create new Apps Script

Monday, April 15, 2019

JIRAでAPIトークンを取得したい


API認証で、Email : Password が廃止になったようです
https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-basic-auth-and-cookie-based-auth/

代わりに Email : API TOKEN が使えるようなのでそれをやってみます



コード.gs
var JIRA_ISSUE_URL = 'https://NAME.atlassian.net/rest/api/2/issue/';

function get_a_issue() {
  var key = "KEY-1";
  var options = {
    contentType: "application/json",
    headers: {"Authorization": " Basic " + get_token()}
  };
  var url = JIRA_ISSUE_URL + key;
  var response = UrlFetchApp.fetch(url, options);
  console.log(response);
}

function get_token() {
  var id = "Email";
  var api_token = "API TOKEN";
  var token = Utilities.base64Encode(id + ":" + api_token);
  return token;
}


API TOKENを取得する道


「Profile」を選択します


「Manage your account」を選択します


「Security」を選択して
「Create and manage API tokens」をクリックします


「Create API token」をクリックします


「Label」に任意の名前を入力します


「View」をクリックすると●●●でマスクされているAPI TOKENが表示されます
「Copy to clipboard」でクリックボードにコピーされます



Latest post

Extracting data from Google Sheets with regular expressions

Introduction Regular expressions are a powerful tool that can be used to extract data from text.  In Google Sheets, regular expressions ca...