pub struct Authorization {
pub client_id: String,
/* private fields */
}
Expand description
Provides for continuing authorization of the app.
Fields§
§client_id: String
Dropbox app key
Implementations§
Source§impl Authorization
impl Authorization
Sourcepub fn from_auth_code(
client_id: String,
flow_type: Oauth2Type,
auth_code: String,
redirect_uri: Option<String>,
) -> Self
pub fn from_auth_code( client_id: String, flow_type: Oauth2Type, auth_code: String, redirect_uri: Option<String>, ) -> Self
Create a new instance using the authorization code provided upon redirect back to your app (or via manual user entry if not using a redirect URI) after the user logs in.
Requires the client ID; the type of OAuth2 flow being used (including the client secret or the PKCE challenge); the authorization code; and the redirect URI used for the original authorization request, if any.
Sourcepub fn save(&self) -> Option<String>
pub fn save(&self) -> Option<String>
Save the authorization state to a string which can be reloaded later.
Returns None
if the state cannot be saved (e.g. authorization has not completed getting a
token yet).
Sourcepub fn load(client_id: String, saved: &str) -> Option<Self>
pub fn load(client_id: String, saved: &str) -> Option<Self>
Reload a saved authorization state produced by save
.
Returns None
if the string could not be recognized. In this case, you should start the
authorization procedure from scratch.
Note that a loaded authorization state is not necessarily still valid and may produce
Authentication
errors. In such a case you should also
start the authorization procedure from scratch.
Sourcepub fn from_refresh_token(client_id: String, refresh_token: String) -> Self
pub fn from_refresh_token(client_id: String, refresh_token: String) -> Self
Recreate the authorization from a refresh token obtained using the Oauth2Type::PKCE
flow.
Sourcepub fn from_client_secret_refresh_token(
client_id: String,
client_secret: String,
refresh_token: String,
) -> Self
pub fn from_client_secret_refresh_token( client_id: String, client_secret: String, refresh_token: String, ) -> Self
Recreate the authorization from a refresh token obtained using the
Oauth2Type::AuthorizationCode
flow. This requires the client secret as well.
Sourcepub fn from_long_lived_access_token(access_token: String) -> Self
👎Deprecated
pub fn from_long_lived_access_token(access_token: String) -> Self
Recreate the authorization from a long-lived access token. This token cannot be refreshed;
any call to obtain_access_token_async
will
simply return the given token. Therefore this requires neither client ID or client secret.
Long-lived tokens are deprecated and the ability to generate them will be removed in the future.
Sourcepub fn obtain_access_token(
&mut self,
sync_client: impl NoauthClient,
) -> Result<String, Error>
Available on crate feature sync_routes
only.
pub fn obtain_access_token( &mut self, sync_client: impl NoauthClient, ) -> Result<String, Error>
sync_routes
only.Compatibility shim for working with sync HTTP clients.
Sourcepub async fn obtain_access_token_async(
&mut self,
client: impl NoauthClient,
) -> Result<String, Error>
pub async fn obtain_access_token_async( &mut self, client: impl NoauthClient, ) -> Result<String, Error>
Obtain an access token. Use this to complete the authorization process, or to obtain an updated token when a short-lived access token has expired.
Trait Implementations§
Source§impl Clone for Authorization
impl Clone for Authorization
Source§fn clone(&self) -> Authorization
fn clone(&self) -> Authorization
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more