Make Registered::complete() accept an AsRef<str>
This patch changes the signature of `Registered::complete` to accept an `AsRef<str>`. This _should_ be backwards compatible to the old version. This change was implemented as it has the neat benefit that a user can implement a type that does not implement `Debug` or `Display`, but only `AsRef<str>`. This can be done to ensure that the access code is not accidentially shown in log output, which might be pasted to some code forge for bug reporting. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
f037379d0f
commit
c32f628c49
|
@ -336,11 +336,15 @@ impl Registered {
|
||||||
|
|
||||||
/// Create an access token from the client id, client secret, and code
|
/// Create an access token from the client id, client secret, and code
|
||||||
/// provided by the authorization url.
|
/// provided by the authorization url.
|
||||||
pub async fn complete(&self, code: &str) -> Result<Mastodon> {
|
pub async fn complete<C>(&self, code: C) -> Result<Mastodon>
|
||||||
let url = format!(
|
where
|
||||||
|
C: AsRef<str>,
|
||||||
|
{
|
||||||
|
let url =
|
||||||
|
format!(
|
||||||
"{}/oauth/token?client_id={}&client_secret={}&code={}&grant_type=authorization_code&\
|
"{}/oauth/token?client_id={}&client_secret={}&code={}&grant_type=authorization_code&\
|
||||||
redirect_uri={}",
|
redirect_uri={}",
|
||||||
self.base, self.client_id, self.client_secret, code, self.redirect
|
self.base, self.client_id, self.client_secret, code.as_ref(), self.redirect
|
||||||
);
|
);
|
||||||
debug!(url = url; "completing registration");
|
debug!(url = url; "completing registration");
|
||||||
let response = self.client.post(&url).send().await?;
|
let response = self.client.post(&url).send().await?;
|
||||||
|
|
Loading…
Reference in New Issue