@mimik/oauth-helper
v3.0.2
Published
Oauth helper for mimik microservices
Downloads
16
Readme
Modules
Typedefs
oauth-helper
Example
const oauthHelper = require('@mimik/oauth-helper');
- oauth-helper
- ~rpAuth(type, options) ⇒ Promise
- ~authProfile(method, id, correlationId, options) ⇒ Promise
oauth-helper~rpAuth(type, options) ⇒ Promise
Make an authorized request.
Kind: inner method of oauth-helper
Returns: Promise - .
Category: async
Throws:
- Promise Will throw the same error than request-promise.
The property token
may be added to options
, in order to set up how the token is retrieved from the token manager. The structure is:
{
"retry": "object to specify how the retry to the token manager will be done. similar to rp-retry retry property",
"customerName": "name of the customer for which the token is entended for, see mST API",
"cluster": "to set the token to be a cluster token"
}
The property metrics
may be added to options
, in order to setup metrics about calls made to other microservice. The structure is:
{
"HTTPrequestDuration": "prom-client function to label and record the elapsed time",
"url": "url to be displayed for the metrics. If not present the url of the options will be used"
}
Requires: module:@mimik/sumologic-winston-logger
Fulfil: object - Response of the request-promise request.
| Param | Type | Description | | --- | --- | --- | | type | string | Type of micro service to request. | | options | object | Options for the request. Similar to request-promise options. |
oauth-helper~authProfile(method, id, correlationId, options) ⇒ Promise
Make an authProfile request to mID.
Kind: inner method of oauth-helper
Returns: Promise - .
Category: async
Throws:
- Promise Will throw a rich error is the request fails or an error if the id is not identified
Requires: module:@mimik/sumologic-winston-logger
Fulfil: object The response of the request made to mID
.
| Param | Type | Description |
| --- | --- | --- |
| method | string | Method (GET
, DELETE
) of the request to be made. |
| id | string | UserId
to associated witht the request. |
| correlationId | UUID.<string> | CorrelationId to associated with the request. |
| options | object | Options to be added to the request. metrics can then be added to the options. |
requestCallback : function
This callback is displayed as a global member.
Kind: global typedef
| Param | Type | Description |
| --- | --- | --- |
| either | object | null
or an error
. |