pub struct CliOAuth { /* private fields */ }
Expand description
The CLI OAuth helper.
Implementations§
Source§impl CliOAuth
impl CliOAuth
Sourcepub fn builder() -> CliOAuthBuilder
pub fn builder() -> CliOAuthBuilder
Constructs a new builder struct for configuration.
Sourcepub fn redirect_url(&self) -> RedirectUrl
pub fn redirect_url(&self) -> RedirectUrl
Generates the redirect URL that will sent in the authorization URL to the identity provider.
Pass the result of this method to oauth2::Client::set_redirect_uri
while building the
client.
Initiates the Authorization Code flow.
The PKCE challenge and verifier are generated. The challenge is used in the authorization URL, and the verifier is saved for the validation step.
The user’s browser is then opened to the authorization URL, and the authorization code (code
) and CSRF token
(state
) are extracted from the redirect request and recorded . These values will also be used in the
validation step, and then returned to the caller for the token exchange.
Sourcepub fn validate(&mut self) -> Result<AuthContext, AuthError>
pub fn validate(&mut self) -> Result<AuthContext, AuthError>
Validates the authorization code and CSRF token (state
).
If validation is successful, then the code and PKCE verifier are returned to the caller in order to build the exchange code request.
This method must be called after CliOAuth::authorize
completes successfully.