pub async fn login_with_username(
    username: &str,
    password: &str,
) -> Result<AuthResponse, reqwest::Error> {
    let url = Url::parse("https://api.genius.com/oauth/token")
        .expect("Could not parse valid URL from login_with_username input.");
    let auth_request = username_auth_body(username, password);
    let client = Client::new();
    let res: AuthResponse = client
        .post(url)
        .json(&auth_request)
        .send()
        .await?
        .json()
        .await?;
    Ok(res)
}
/// Log into an account with username and password the response will be [`AuthResponse`]. The response token will be level `user-core`.
/// #### Examples
/// Basic usage:
/// ```
/// use genius_rs::auth::login;
///
/// # async fn run() -> Result<(), reqwest::Error> {
/// let auth = login::login_with_username("username", "password")
///     .await
///     .expect("Error requesting login with username");
///
/// match auth.access_token {
///     Some(token) => println!("The token is: {}.", token),
///     None => println!("Incorrect username or password."),
/// }
/// # Ok(())
/// # }
/// ```
Log into an account with username and password the response will be [`AuthResponse`]. The response token will be level `user-core`.
Log into an account with username and password the response will be [ ` AuthResponse ` ] . The response token will be level ` user - core ` .
pub async fn login_with_username(
    username: &str,
    password: &str,
) -> Result<AuthResponse, reqwest::Error> {
    let url = Url::parse("https://api.genius.com/oauth/token")
        .expect("Could not parse valid URL from login_with_username input.");
    let auth_request = username_auth_body(username, password);
    let client = Client::new();
    let res: AuthResponse = client
        .post(url)
        .json(&auth_request)
        .send()
        .await?
        .json()
        .await?;
    Ok(res)
}
pub async fn login_with_username ( username : & str , password : & str , ) -> Result < AuthResponse , reqwest :: Error > { let url = Url :: parse ( " " ) . expect ( " " ) ; let auth_request = username_auth_body ( username , password ) ; let client = Client :: new ( ) ; let res : AuthResponse = client . post ( url ) . json ( & auth_request ) . send ( ) . await ? . json ( ) . await ? ; Ok ( res ) }
Log into an account with username and password the response will be [`AuthResponse`].
Log into an account with username and password the response will be [ ` AuthResponse ` ] .
username
&str
password
&str
username
&str
password
&str
examples
Basic usage:
```
use genius_rs::auth::login.
Basic usage : ` ` ` use genius_rs :: auth :: login .
async fn run() -> result<(), reqwest::error> {
let auth = login::login_with_username("username", "password")
.await
.expect("Error requesting login with username").

match auth.access_token {
Some(token) => println!("The token is: {}.", token),
None => println!("Incorrect username or password."),
}
let auth = login :: login_with_username ( " username " " password " ) . await . expect ( " Error requesting login with username " ) . match auth . access_token { Some ( token ) = > println! ( " The token is : {} . " token ) None = > println! ( " Incorrect username or password . " ) }
ok(())
None
}
None