5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【GAS】Google Apps Script API をオンにしているのに、拡張機能 GitHub アシスタントで、[github assistant] undefined がでる問題

Last updated at Posted at 2022-07-06

追記です

複数アカウント使ってる場合は、chromeのアカウント(プロファイル)自体を切り替えるのが一番よさそうです

スクリーンショット 2023-01-08 9.24.48.png

問題

発生した事象

Google Apps Scriptで、pushやpullをしようとすると以下のエラーが発生
[github assistant] undefined

スクリーンショット 2022-07-06 7.30.41.png

Chromeの検証機能でネットワークを確認すると、

スクリーンショット 2022-07-06 7.46.30.png

{
  "error": {
    "code": 401,
    "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED"
  }
}

発生条件

こちらの記事を参考に、githubと正しく連携

また、こちらの記事を参考に、Google Apps Script API をオンにしている

解決策

Chrome上部のメニューバーの「ウィンドウ」
=> 拡張機能
=> 「Google Apps Script GitHub アシスタント」の詳細
=> 「拡張機能のオプション」を押下

「拡張機能のオプション」を押下時に以下のようなポップアップが表示されることがある。
※どういう条件の時にポップアップが表示されるかがハッキリとわからず、、googleアカウントを一度ログインしなおす等するとポップアップが表示するっぽい :thinking:

スクリーンショット 2022-07-05 16 37 10

以下の画面に進むので、GasHubにGoogleアカウントへのアクセスの認可を行います。

スクリーンショット 2022-07-05 16 37 10

補足

エラーにもいくつかバリエーションがあるっぽい。
同じ401でも、以下のようにdetailsがついてるケースもあったが、この場合も上記の方法で解決した。

{
  "error": {
    "code": 401,
    "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
    "status": "UNAUTHENTICATED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "CREDENTIALS_MISSING",
        "domain": "googleapis.com",
        "metadata": {
          "service": "script.googleapis.com",
          "method": "google.apps.script.management.v1.ProjectsService.GetContent"
        }
      }
    ]
  }
}

発生条件が定かでなく、再現できていないが、403 PERMISSION_DENIEDが返ってくるケースもあったが、こちらも上記の手法で解決した。

{
  "error": {
    "code": 403,
    "message": "The caller does not have permission",
    "status": "PERMISSION_DENIED"
  }
}

追記

複数のGoogleアカウントを切り替えたりしてるとGithubとの連携がおかしくなるので、Chromeのユーザーを切り替えましょう。

5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?