Struct OAuthApi

Source
pub struct OAuthApi { /* private fields */ }

Implementations§

Source§

impl OAuthApi

Source

pub fn new(square_client: SquareClient) -> OAuthApi

Instantiates a new OAuthApi

Source

pub async fn authorize( &self, params: &AuthorizeOAuthParameters, ) -> Result<AuthorizeOAuthResponse, SquareApiError>

As part of a URL sent to a seller to authorize permissions for the developer, Authorize displays an authorization page and a list of requested permissions.

The completed URL looks similar to the following example: https://connect.squareup.com/oauth2/authorize?client_id={YOUR_APP_ID}&scope=CustomersWrite+CustomersRead&session=False&state=82201dd8d83d23cc8a48caf52b

Learn more (https://developer.squareup.com/reference/square/o-auth-api/authorize).

Source

pub async fn revoke_token( &self, application_secret: &str, body: &RevokeTokenOAuthRequest, ) -> Result<RevokeTokenOAuthResponse, SquareApiError>

Revokes an access token generated with the OAuth flow.

If an account has more than one OAuth access token for your application, this endpoint revokes all of them, regardless of which token you specify.

Important: The Authorization header for this endpoint must have the following format: Authorization: Client APPLICATION_SECRET

Source

pub async fn obtain_token( &self, body: &ObtainTokenOAuthRequest, ) -> Result<ObtainTokenOAuthResponse, SquareApiError>

Returns an OAuth access token and a refresh token unless the short_lived parameter is set to true, in which case the endpoint returns only an access token.

The grant_type parameter specifies the type of OAuth request. If grant_type is AuthorizationCode, you must include the authorization code you received when a seller granted you authorization. If grant_type is RefreshToken, you must provide a valid refresh token. If you’re using an old version of the Square APIs (prior to March 13, 2019), grant_type can be MigrationToken and you must provide a valid migration token.

You can use the scopes parameter to limit the set of permissions granted to the access token and refresh token. You can use the short_lived parameter to create an access token that expires in 24 hours.

Note: OAuth tokens should be encrypted and stored on a secure server. Application clients should never interact directly with OAuth tokens.

Source

pub async fn retrieve_token_status( &self, access_token: impl AsRef<str>, ) -> Result<RetrieveTokenStatusResponse, SquareApiError>

Returns information about an OAuth access token or an application’s personal access token. Add the access token to the Authorization header of the request.

Important: The Authorization header you provide to this endpoint must have the following format: Authorization: Bearer ACCESS_TOKEN where ACCESS_TOKEN is a valid production authorization credential. If the access token is expired or not a valid access token, the endpoint returns an UNAUTHORIZED error.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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
Source§

impl<T> ErasedDestructor for T
where T: 'static,