diff options
author | D. Scott Boggs <scott@tams.tech> | 2023-09-29 06:15:23 -0400 |
---|---|---|
committer | D. Scott Boggs <scott@tams.tech> | 2023-09-29 07:12:40 -0400 |
commit | 1eecdeef999dbdfe69ce5df7dafe724073d97f6d (patch) | |
tree | 956aa9d085bdc4dec6f90ae76898282830c4955b | |
parent | 010b958c076f2fce21ab6c9312fcf3d1b9084ea9 (diff) |
Add OAuth revocation methodcomb-methods/oauth-revoke
-rw-r--r-- | entities/src/auth/mod.rs | 6 | ||||
-rw-r--r-- | entities/src/forms/oauth/token/acquisition.rs (renamed from entities/src/forms/oauth/token.rs) | 0 | ||||
-rw-r--r-- | entities/src/forms/oauth/token/mod.rs | 5 | ||||
-rw-r--r-- | entities/src/forms/oauth/token/revocation.rs | 23 | ||||
-rw-r--r-- | src/mastodon.rs | 2 |
5 files changed, 36 insertions, 0 deletions
diff --git a/entities/src/auth/mod.rs b/entities/src/auth/mod.rs index 7a125a2..3fbda74 100644 --- a/entities/src/auth/mod.rs +++ b/entities/src/auth/mod.rs @@ -3,8 +3,14 @@ pub mod scopes; pub mod token; pub use scopes::{Scope, Scopes}; +use serde::{Deserialize, Serialize}; pub use token::Token; pub mod prelude { pub use super::{scopes, Scope, Scopes, Token}; } + +/// The empty object is returned by a request to revoke an OAuth token. This +/// type represents that. +#[derive(Debug, Default, Copy, Clone, Deserialize, Serialize)] +pub struct RevocationResponse {} diff --git a/entities/src/forms/oauth/token.rs b/entities/src/forms/oauth/token/acquisition.rs index c47bf21..c47bf21 100644 --- a/entities/src/forms/oauth/token.rs +++ b/entities/src/forms/oauth/token/acquisition.rs diff --git a/entities/src/forms/oauth/token/mod.rs b/entities/src/forms/oauth/token/mod.rs new file mode 100644 index 0000000..d40e417 --- /dev/null +++ b/entities/src/forms/oauth/token/mod.rs @@ -0,0 +1,5 @@ +mod acquisition; +pub mod revocation; + +pub use acquisition::*; +pub use revocation::Revocation; diff --git a/entities/src/forms/oauth/token/revocation.rs b/entities/src/forms/oauth/token/revocation.rs new file mode 100644 index 0000000..b64a970 --- /dev/null +++ b/entities/src/forms/oauth/token/revocation.rs @@ -0,0 +1,23 @@ +use serde::{Deserialize, Serialize}; + +use crate::{ClientId, ClientSecret, OAuthToken}; + +/// Form to be submitted when revoking an OAuth token. +/// +/// See also the [API Documentation](https://docs.joinmastodon.org/methods/oauth/#revoke) +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] +pub struct Revocation { + client_id: ClientId, + client_secret: ClientSecret, + token: OAuthToken, +} + +impl Revocation { + pub fn new(client_id: ClientId, client_secret: ClientSecret, token: OAuthToken) -> Self { + Self { + client_id, + client_secret, + token, + } + } +} diff --git a/src/mastodon.rs b/src/mastodon.rs index caafce1..795fabb 100644 --- a/src/mastodon.rs +++ b/src/mastodon.rs @@ -189,6 +189,8 @@ impl Mastodon { [patch] update_credentials(account::Credentials)@"/api/v1/accounts/update_credentials" -> Account, "Post a new status to the account." [post] new_status(NewStatus)@"/api/v1/statuses" -> Status, + "Revoke an access token to make it no longer valid for use." + [post] revoke_auth(forms::oauth::token::Revocation)@"/oauth/revoke" -> auth::RevocationResponse, } /// Edit existing status |