Struct dropbox_sdk::oauth2::Authorization
source · pub struct Authorization { /* private fields */ }
Expand description
Provides for continuing authorization of the app.
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 an authorization code and refresh token.
sourcepub fn from_access_token(access_token: String) -> Self
pub fn from_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
will simply return
the given token.
sourcepub fn obtain_access_token(
&mut self,
client: impl NoauthClient
) -> Result<String>
pub fn obtain_access_token( &mut self, client: impl NoauthClient ) -> Result<String>
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