Struct ramp_api::auths::Auths

source ·
pub struct Auths {
    pub client: Client,
}

Fields§

§client: Client

Implementations§

source§

impl Auths

source

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 !RefUnwindSafe for Auths

§

impl Send for Auths

§

impl Sync for Auths

§

impl Unpin for Auths

§

impl !UnwindSafe for Auths

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

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