Stores a credential for a model provider (for example "openrouter") or for an MCP server
("mcp:<server>"). With method = "auto", providers and MCP servers that support OAuth
get the authorization-code flow with PKCE (S256): a page on 127.0.0.1 receives the redirect
when 'httpuv' and 'later' are installed; otherwise you paste the address your browser ends
on. Everything else gets masked key entry. Credentials go to the credential store
(auth.json, readable only by you, or a keyring reference); access tokens stay in memory.
A tool call never opens a browser: when an MCP server needs a sign-in, the call fails with
an error naming this function.
Usage
gptr_login(provider, method = c("auto", "oauth", "key"))
gptr_logout(provider)Value
gptr_login() returns TRUE invisibly; gptr_logout() removes the stored
credential and forgets the access token held in memory, and returns TRUE invisibly when
it removed something, else FALSE.
Examples
if (interactive()) {
gptr_login("openrouter")
gptr_logout("openrouter")
}