Return the github oauth_token from the VS Code / IntelliJ plugin config, or the empty string if no usable entry exists. apps.json layout: {"github.com: ": {"oauth_token": "gho_...", "user": "...", "scopes": [...], ...}} Several github.com:*
()
| 108 | |
| 109 | |
| 110 | def _read_plugin_source_token() -> str: |
| 111 | """Return the github oauth_token from the VS Code / IntelliJ plugin |
| 112 | config, or the empty string if no usable entry exists. |
| 113 | |
| 114 | apps.json layout: |
| 115 | {"github.com:<appId>": {"oauth_token": "gho_...", "user": "...", |
| 116 | "scopes": [...], ...}} |
| 117 | Several github.com:* keys may exist (e.g. one per workspace); the |
| 118 | first entry with a non-empty oauth_token wins. |
| 119 | """ |
| 120 | for path in (COPILOT_PLUGIN_APPS, COPILOT_PLUGIN_HOSTS): |
| 121 | if not path.exists(): |
| 122 | continue |
| 123 | data = read_json_file(path) |
| 124 | if data is None: |
| 125 | _log.debug("Could not parse %s", path) |
| 126 | continue |
| 127 | for key, entry in data.items(): |
| 128 | if not isinstance(entry, dict): |
| 129 | continue |
| 130 | if "github.com" not in key: |
| 131 | continue |
| 132 | tok = entry.get("oauth_token") or entry.get("user_token") or "" |
| 133 | if isinstance(tok, str) and tok.strip(): |
| 134 | return tok.strip() |
| 135 | return "" |
| 136 | |
| 137 | |
| 138 | def _resolve_source_token() -> tuple[str, str]: |
no test coverage detected