pub struct Auths {
pub client: Client,
}Fields§
§client: ClientImplementations§
Source§impl Auths
impl Auths
Sourcepub async fn post_token(&self) -> Result<Response<OAuth2Token>, ClientError>
pub async fn post_token(&self) -> Result<Response<OAuth2Token>, ClientError>
Get OAuth2 token.
This function performs a POST to the /token endpoint.
Returns an access token for accessing endpoints. There are three methods to get an access token:
- “authorization_code”: Authorization Code Grant method, used for retrieving an access token for the first time
- “refresh_token”: Refresh Token method, used for retrieving subsequent access tokens using the refresh token provided from authorization code grant
- “client_credentials”: Client Credentials method, allows direct retrieval of access tokens with only client id and secret.
There are two main flows: Authorization Code Grant + Refresh Token; or Client Credentials.
For Authorization Code Grant + Refresh Token, the flow would be as follows:
- Follow authorization process to get an authorization code
- Use authorization code to retrieve an access token and refresh token from this endpoint
- Use refresh token to retrieve new access tokens from this endpoint (without having to go through authorization process again)
For Client Credentials:
- Call token endpoint with client credentials to retrieve access token
The request body is different for the methods:
- grant_type = “authorization_code”
- code
- redirect_uri
- grant_type = “refresh_token”
- refresh_token
- grant_type = “client_credentials”
- no additional data
Some important notes:
- Unlike other endpoints, the data format must be “application/x-www-form-urlencoded”, according to RFC specifications
- To use a particular code grant, it must be included in the “Grant Types” section of the App Settings modal in app.ramp.com
- Only the authorization code grant returns a refresh token
- Additionally, the “Refresh Token” grant type must be selected in App Settings for the refresh token to be returned
- The token endpoint used to be “/public/v1/customer/token” - this endpoint is now deprecated and should not be used
Parameters:
authorization: &str– Basic <base64-encoded client_id:client_secret>.
Auto Trait Implementations§
impl Freeze for Auths
impl !RefUnwindSafe for Auths
impl Send for Auths
impl Sync for Auths
impl Unpin for Auths
impl UnsafeUnpin for Auths
impl !UnwindSafe for Auths
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more