async-oauth2
async-oauth2 copied to clipboard
I don't understand how to use token
I obtained a token:
let token = client.exchange_client_credentials()
.with_client(&reqwest_client)
.execute::<StandardToken>().await.unwrap(); // FIXME: unwrap()
Now I don't understand how to use it to make a Reqwest request.
You should provide documentation and an example.
It depends on the service, with for example Twitch you send a Authorization: Bearer <token> header for each request.
I meant to ask a different thing:
How do I convert the token to string that goes after Bearer?
You get the access token through Token::access_token which derefs to str, so it can be used as a string.
So like this:
use oauth2::Token;
let token = /* */;
println!("{}", token.access_token());
let token_as_string = token.access_token().to_string();