YaasApiOAuth2V1
TypeScript abstraction library for RAML-based REST API YaasApiOAuth2V1.
Auto-generated using raml-typescript-generator.
Installation
npm install yaas-api-oauth-2-v1 --save
Usage
TypeScript
;...constructor..
To support multiple versions of the API, it is recommended to alias the import so it can easily be mapped to a later API version - and, due to the nature of Typescript, you should be alerted on API signature changes already at compile time:
;
JS (Legacy)
API skeleton as it would be produced by MuleSoft's raml-javascript-generator JS generator is shipped for reference and to ease migrations:
var YaasApiOauth2V1 = var client =
Options
You can set options when you initialize a client or at any time with the options
property. You may also override options per request by passing an object as the last argument of request methods. For example:
client = ...
For dynamic header injection - for example required for non-standard REST services asking for custom authentication token - a provider may be defined:
client = { returnthismyToken ? Authorization: "Bearer " + thismyToken : {} };
Base URI
By default, endpoint as defined in RAML file https://api.eu.yaas.io/hybris/oauth2/v1
is used.
Note If supported by API provider, it is recommended to use one API version definition (i.e. RAML file and corresponding API TypeScript library) and switch endpoint based on the desired environment, for example test
, qa
or prod
You can override the base URI by setting the baseUri
property, or initializing a client with a base URI. For example:
baseUri: 'https://api.eu.yaas.io/hybris/oauth2/anotherVersion';
Methods
All methods return an Observable wrapping a Popsicle obtained response:
revoke.post([body, [options]])
Revokes given access token.
clientrevoke
authorize.get([query, [options]])
Starts the authorization procedure with the parameters specified in the URL query.
clientauthorize
authorize.post([body, [options]])
This starts the authorization procedure with the parameters specified in the request body (form parameters).
clientauthorize
token.post([body, [options]])
Use only ONE of the authorization types:
- [RECOMMENDED] `Authorization` header, OR
- `client_id` and `client_secret` body parameters. Remove the content of the prefilled Authorization Basic example when you use this authorization type.
Examples:
- Client Credentials grant type
curl -X POST 'https://api.beta.yaas.io/hybris/oauth2/v1/token' \ -d 'grant_type=client_credentials&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&scope=scope1' \ -H 'content-type: application/x-www-form-urlencoded'
- Resource Owner Password Credentials grant type
curl -X POST 'https://api.beta.yaas.io/hybris/oauth2/v1/token' \ -d 'grant_type=password&client_id=CLIENT_ID&client_secret=CLIENT_SECRET&username=USERNAME&password=USER_PASSWORD&scope=scope1' \ -H 'content-type: application/x-www-form-urlencoded'
clienttoken
userinfo.get([query, [options]])
Returns claims about the authenticated end user.
clientuserinfo
userinfo.post([body, [options]])
Returns claims about the authenticated end user.
clientuserinfo
tokeninfo.get([query, [options]])
When the query parameters access_token is provided, this endpoint returns tenant, scopes, allowedServices, etc. associated with the access token.
clienttokeninfo
License
Apache 2.0