| Crates.io | inaturalist-oauth |
| lib.rs | inaturalist-oauth |
| version | 0.1.0 |
| created_at | 2025-09-25 18:11:04.961905+00 |
| updated_at | 2025-09-25 18:11:04.961905+00 |
| description | A Rust library for OAuth authentication with iNaturalist |
| homepage | |
| repository | https://github.com/frewsxcv/rust-inaturalist |
| max_upload_size | |
| id | 1854954 |
| size | 56,203 |
This crate provides a simple way to obtain an iNaturalist API token using the OAuth2 authorization flow.
The primary entry point is the Authenticator. You use it to configure your application's client ID and secret, and then call get_api_token(). When called, it will:
http://localhost:8080, but is configurable).This process provides a user-friendly way for a command-line application to get authorization to access the iNaturalist API on behalf of a user. The calling application is responsible for storing and retrieving the token for subsequent use.
Add this to your Cargo.toml:
[dependencies]
inaturalist-oauth = { path = "../inaturalist-oauth" }
Then, you can use it in your code like this:
use inaturalist_oauth::Authenticator;
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 api_token = Authenticator::new(client_id, client_secret)
.with_redirect_server_port(8081)
.get_api_token()?;
println!("Got iNaturalist API token: {}", api_token);
// Now you can use this token to make authenticated requests to the iNaturalist API.
Ok(())
}