pub struct OAuthApi { /* private fields */ }
Implementations§
Source§impl OAuthApi
impl OAuthApi
Sourcepub fn new(square_client: SquareClient) -> OAuthApi
pub fn new(square_client: SquareClient) -> OAuthApi
Instantiates a new OAuthApi
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).
Sourcepub async fn revoke_token(
&self,
application_secret: &str,
body: &RevokeTokenOAuthRequest,
) -> Result<RevokeTokenOAuthResponse, SquareApiError>
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
Sourcepub async fn obtain_token(
&self,
body: &ObtainTokenOAuthRequest,
) -> Result<ObtainTokenOAuthResponse, SquareApiError>
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.
Sourcepub async fn retrieve_token_status(
&self,
access_token: impl AsRef<str>,
) -> Result<RetrieveTokenStatusResponse, SquareApiError>
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.