MCPcopy Create free account
hub / github.com/BitterSecurity/Decepticon / _read_plugin_source_token

Function _read_plugin_source_token

config/copilot_handler.py:110–135  ·  view source on GitHub ↗

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:*

()

Source from the content-addressed store, hash-verified

108
109
110def _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
138def _resolve_source_token() -> tuple[str, str]:

Callers 1

_resolve_source_tokenFunction · 0.85

Calls 3

read_json_fileFunction · 0.90
existsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected