spacr.qt.ai.github_auth¶
GitHub authentication + direct issue creation for spaCR.
Lets users file approved issues WITHOUT a browser round-trip. A token is
resolved from the GITHUB_TOKEN / GH_TOKEN environment or the GitHub
CLI (gh auth token). spaCR does not capture or persist credentials; the
official CLI owns interactive login and its platform credential store.
When a token is available, create_issue() POSTs straight to the GitHub
REST API and returns the created issue’s URL. When none is available the caller
falls back to opening the pre-filled issues/new URL in the browser.
Public API:
github_auth.is_authenticated() -> bool
github_auth.auth_source() -> "token" | "env" | "gh" | None
github_auth.create_issue(repo, title, body, labels) -> (ok, url_or_error)
Functions¶
|
Where the active token comes from — 'token' | 'env' | 'gh' | None. |
|
Add a comment to an existing issue. |
|
Create a GitHub issue directly via the REST API. |
|
Find an open GitHub issue containing a diagnostic fingerprint. |
|
Return a process-only token, after erasing insecure legacy storage. |
|
True iff a GitHub token is available from any source. |
|
Return |
|
Set a process-only compatibility token; never persist it. |
Module Contents¶
- spacr.qt.ai.github_auth.auth_source() str | None[source]¶
Where the active token comes from — ‘token’ | ‘env’ | ‘gh’ | None.
- spacr.qt.ai.github_auth.comment_on_issue(repo: str, number: int, body: str) Tuple[bool, str][source]¶
Add a comment to an existing issue.
- Parameters:
repo –
owner/nameslug.number – the issue number.
body – markdown comment body.
- Returns:
(True, comment_html_url)on success, else(False, error).
- spacr.qt.ai.github_auth.create_issue(repo: str, title: str, body: str, labels: List[str] | None = None) Tuple[bool, str][source]¶
Create a GitHub issue directly via the REST API.
- Parameters:
repo –
owner/nameslug.title – issue title.
body – markdown body.
labels – labels to attach (created lazily by GitHub if new).
- Returns:
(True, issue_html_url)on success, else(False, error).
- spacr.qt.ai.github_auth.find_issue_by_fingerprint(repo: str, fingerprint: str) Tuple[bool, dict | None][source]¶
Find an open GitHub issue containing a diagnostic fingerprint.
- Parameters:
- Returns:
search_completed (bool) –
Truewhen GitHub returned a search result, including no matches.Falsewhen authentication is unavailable or the search fails.issue (dict or None) – First matching issue, or
Nonewhen no issue was found or the search could not be completed.
- spacr.qt.ai.github_auth.get_stored_token() str[source]¶
Return a process-only token, after erasing insecure legacy storage.
- spacr.qt.ai.github_auth.is_authenticated() bool[source]¶
True iff a GitHub token is available from any source.
- spacr.qt.ai.github_auth.resolve_token() Tuple[str, str | None][source]¶
Return
(token, source)— source is ‘token’ | ‘env’ | ‘gh’ | None.
- spacr.qt.ai.github_auth.set_stored_token(token: str) None[source]¶
Set a process-only compatibility token; never persist it.
The GUI no longer exposes this function. It remains for API callers and offline transport tests that need to inject a credential for one process. Interactive users authenticate with
gh auth login.- Parameters:
token – the GitHub token to hold in memory for this process; surrounding whitespace is stripped, and an empty value or
Noneclears it. Any token left inQSettingsby older builds is removed.