Expand description
This crate provides a simple way to obtain an iNaturalist API token using the OAuth2 authorization flow. It handles the process of opening a web browser for user authorization, running a temporary local server to catch the redirect, and exchanging the authorization code for an API token.
§Usage
use inaturalist_oauth::Authenticator;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client_id = "YOUR_CLIENT_ID".to_string();
let client_secret = "YOUR_CLIENT_SECRET".to_string();
let token_details = Authenticator::new(client_id, client_secret)
.with_redirect_server_port(8081)
.get_api_token()
.await?;
println!("Got iNaturalist API token: {}", token_details.api_token);
Ok(())
}Structs§
- Authenticator
- Handles the iNaturalist OAuth2 flow to obtain an API token.
- Authorization
Info - Information needed to complete the authorization process after the user is redirected.
- Pkce
Verifier - A wrapper for the PKCE verifier to ensure type safety.
- Token
Details - Contains the iNaturalist API token and its expiration details.