pub struct AuthCodeAuthorizationUrlParameters { /* private fields */ }
Expand description

Get the authorization url required to perform the initial authorization and redirect in the authorization code flow.

The authorization code flow begins with the client directing the user to the /authorize endpoint.

The OAuth 2.0 authorization code grant type, or auth code flow, enables a client application to obtain authorized access to protected resources like web APIs. The auth code flow requires a user-agent that supports redirection from the authorization server (the Microsoft identity platform) back to your application. For example, a web browser, desktop, or mobile application operated by a user to sign in to your app and access their data.

Reference: https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code

§Build a confidential client for the authorization code grant.

Use with_authorization_code to set the authorization code received from the authorization step, see Request an authorization code You can use the AuthCodeAuthorizationUrlParameterBuilder to build the url that the user will be directed to authorize at.

use uuid::Uuid;
use graph_oauth::{AzureCloudInstance, ConfidentialClientApplication, Prompt};
use url::Url;

let auth_url_builder = ConfidentialClientApplication::builder(Uuid::new_v4())
    .auth_code_url_builder()
    .with_tenant("tenant-id")
    .with_prompt(Prompt::Login)
    .with_state("1234")
    .with_scope(vec!["User.Read"])
    .with_redirect_uri(Url::parse("http://localhost:8000").unwrap())
    .build();

let url = auth_url_builder.url();
// or
let url = auth_url_builder.url_with_host(&AzureCloudInstance::AzurePublic);

Implementations§

source§

impl AuthCodeAuthorizationUrlParameters

source

pub fn new( client_id: impl AsRef<str>, redirect_uri: impl IntoUrl ) -> IdentityResult<AuthCodeAuthorizationUrlParameters>

source

pub fn builder( client_id: impl TryInto<Uuid> ) -> AuthCodeAuthorizationUrlParameterBuilder

source

pub fn url(&self) -> IdentityResult<Url>

source

pub fn url_with_host( &self, azure_cloud_instance: &AzureCloudInstance ) -> IdentityResult<Url>

source

pub fn into_credential( self, authorization_code: impl AsRef<str> ) -> AuthorizationCodeCredentialBuilder

source

pub fn into_assertion_credential( self, authorization_code: impl AsRef<str> ) -> AuthorizationCodeAssertionCredentialBuilder

source

pub fn nonce(&mut self) -> Option<&String>

Get the nonce.

This value may be generated automatically by the client and may be useful for users who want to manually verify that the nonce stored in the client is the same as the nonce returned in the response from the authorization server. Verifying the nonce helps mitigate token replay attacks.

Trait Implementations§

source§

impl AuthorizationUrl for AuthCodeAuthorizationUrlParameters

source§

impl Clone for AuthCodeAuthorizationUrlParameters

source§

fn clone(&self) -> AuthCodeAuthorizationUrlParameters

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for AuthCodeAuthorizationUrlParameters

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more