pub struct AuthorizationUrl {
pub client_id: String,
pub redirect_uri: String,
pub code_challenge: String,
pub scope: Option<String>,
pub username: Option<String>,
pub state: Option<String>,
/* private fields */
}Expand description
Parameters for the OAuth2 authorization endpoint.
This endpoint is not called by this library: it renders an authorization
prompt for the user in a browser, and the result is delivered as query
parameters appended to your redirect_uri.
response_type and code_challenge_method are fixed by the spec and are
set for you.
§Example
use lichess_api::model::oauth::authorize::AuthorizationUrl;
let (url, pending) = AuthorizationUrl::generated("example.com", "http://example.com/")
.scope("preference:read")
.start()?;
// Send the user to `url`, and keep `pending` until they are redirected back.AuthorizationUrl::start generates the PKCE secrets and the state for
you, and returns a PendingAuthorization that verifies the result and
completes the exchange. Use AuthorizationUrl::new with
AuthorizationUrl::to_url only if you are managing those secrets
yourself, and keep the code_verifier out of URLs and off insecure
connections.
Fields§
§client_id: StringArbitrary identifier that uniquely identifies your application.
redirect_uri: StringThe absolute URL the user should be redirected to with the result.
code_challenge: StringBASE64URL(SHA256(code_verifier)).
scope: Option<String>Space separated list of requested OAuth scopes, if any.
username: Option<String>Hint that the user should log in with a specific Lichess username.
state: Option<String>Arbitrary state returned verbatim with the authorization result.
Implementations§
Source§impl AuthorizationUrl
impl AuthorizationUrl
Sourcepub fn generated(
client_id: impl Into<String>,
redirect_uri: impl Into<String>,
) -> Self
pub fn generated( client_id: impl Into<String>, redirect_uri: impl Into<String>, ) -> Self
Start an authorization request whose PKCE secrets and state are
generated for you by AuthorizationUrl::start.
Prefer this over AuthorizationUrl::new unless you are managing the
PKCE secrets yourself.
Sourcepub fn new(
client_id: impl Into<String>,
redirect_uri: impl Into<String>,
code_challenge: impl Into<String>,
) -> Self
pub fn new( client_id: impl Into<String>, redirect_uri: impl Into<String>, code_challenge: impl Into<String>, ) -> Self
Build an authorization request from a code_challenge you computed
yourself.
The challenge is BASE64URL(SHA256(code_verifier)); see
Pkce::derive_challenge. Most callers should use
AuthorizationUrl::generated with AuthorizationUrl::start instead.
Sourcepub fn scope(self, scope: impl Into<String>) -> Self
pub fn scope(self, scope: impl Into<String>) -> Self
Space separated list of requested OAuth scopes.
Sourcepub fn username(self, username: impl Into<String>) -> Self
pub fn username(self, username: impl Into<String>) -> Self
Hint that the user should log in with a specific Lichess username.
Sourcepub fn state(self, state: impl Into<String>) -> Self
pub fn state(self, state: impl Into<String>) -> Self
Arbitrary state returned verbatim with the authorization result.
Sourcepub fn start(self) -> Result<(Url, PendingAuthorization)>
pub fn start(self) -> Result<(Url, PendingAuthorization)>
Begin an authorization request, generating the PKCE secrets and state
for you.
Returns the URL to send the user to, and a PendingAuthorization
holding the secrets needed to complete the flow. Store the pending value
for the duration of the request (in session storage for a web backend,
in memory for a native app) and finish with
PendingAuthorization::complete.
Any state set on this builder is replaced by a freshly generated one.
Use PendingAuthorization::new directly if you must supply your own.
Trait Implementations§
Source§impl Clone for AuthorizationUrl
impl Clone for AuthorizationUrl
Source§fn clone(&self) -> AuthorizationUrl
fn clone(&self) -> AuthorizationUrl
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more