Skip to main content

verify_token

Function verify_token 

Source
pub fn verify_token(host: &Host, token: &str) -> Result<String, GorError>
Expand description

Verify that an OAuth token is valid by calling GET /user.

Returns the authenticated user’s login name on success.

§Errors

Returns GorError::Auth if the token is invalid or the request fails.

§Examples

use gor::auth::token::verify_token;
use gor::host::Host;

let host = Host::new("github.com");
let login = verify_token(&host, "gho_abc123").unwrap();
println!("Authenticated as {login}");