mangadex_api::v5::oauth

Module refresh_token

Source
Available on crate feature oauth only.
Expand description

Builder for the OAuth login endpoint.

https://api.mangadex.org/docs/02-authentication/

It’s the support for Personal Client

§Examples

use mangadex_api_types::{Password, Username};
use mangadex_api::v5::MangaDexClient;
use mangadex_api_schema::v5::oauth::ClientInfo;


let mut client = MangaDexClient::default();

client.set_client_info(&ClientInfo {
    client_id: "someClientId".to_string(),
    client_secret: "someClientSecret".to_string()
}).await?;

// Login to your account

let login_res = client
    .oauth()
    .login()
    .username(Username::parse("myusername")?)
    .password(Password::parse("hunter2")?)
    .send()
    .await?;

println!("login: {:?}", login_res);

// Wait until the access token expires
tokio::time::sleep(tokio::time::Duration::from_secs(<usize as TryInto<u64>>::try_into(login_res.expires_in)?)).await;

let refresh_res = client
    .oauth()
    .refresh()
    .send()
    .await?;

println!("refresh: {:?}", refresh_res);

Structs§