Retrieves a GitHub personal access token (PAT) from one of several sources, depending on the environment in which the code is running. Sources are tried in the following order:
1. **Posit Connect** — if the `CONNECT_SERVER` environment variable is set, OAuth content credentials are retrieved via `connectapi`. 2. **Keyring** — if a secret matching `env_var` exists in the system keyring, it is returned. This is the preferred local approach. 3. **Environment variable** — if `env_var` is set in the global or project-level `.Renviron`, that value is returned.
If none of these sources yields a token, the function stops with a message guiding the user to set credentials via `keyring::key_set()` or `.Renviron`.
Value
A string containing the GitHub PAT, or a Posit Connect OAuth credentials object when running on Connect.