Create a new grant from grant data received back from commercetools.
The access token string needed when making requests to commercetools. If this was generated by a customer logging in, then this is used by commercetools to identify the customer.
Optional
anonymousWhen this grant came from a call to {@see CommercetoolsAuth.getAnonymousGrant} or {@see CommercetoolsApi.getAnonymousGrant} then the value will be populated with the id of the anonymous customer to which this grant relates.
Optional
customerWhen this grant is generated from a call to {@see CommercetoolsAuth.login} or {@see CommercetoolsApi.login} then this value will be populated with the id of the customer to which this grant relates.
This is the expiry date/time of the access token. This is calculated based
on the expiredIn
property, and as such may be very slightly after the
internal commercetools expiry date (due to the time involved to receive
and process the response.
The duration of the access token in seconds (typically 48 hours)
Optional
refreshThe refresh token is required for refreshing an existing grant. A refresh token is only issued for customer grants (either logged in or anonymous), an not for client grants.
List of permission scopes. This will also include the anonymous_id
when
generating an anonymous customer token, or the customer_id
when logging
in as an existing customer.
Calculates whether the grant is due to expire within a given number of seconds. This is useful when deciding if the expiry date/time is close enough to warrant pro-active renewal, rather than waiting for expiry.
Given a scope string (as returned from commercetools), this method extracts the value of the associated with the given key. Used for retrieving the anonymous id and customer id from the scope string.
Holds the details of the grant returned from commercetools in response to an authorisation API related request: https://docs.commercetools.com/api/authorization