npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yaas-api-oauth2-v1

v0.1.0

Published

TypeScript API client-lib for YAAS 'oauth2' based on (fixed) version on Hybris SAP published API RAML, see https://devportal.yaas.io/services/oauth2/v1/ [Auto-generated using raml-typescript-generator]

Downloads

2

Readme

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

import {YaasApiOauth2V1} from 'yaas-api-oauth-2-v1';
...
constructor(..) {
  this.yaasApiOauth2V1 = new YaasApiOauth2V1({});
}

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:

import {YaasApiOauth2V1 as YaasApiOauth2} from 'yaas-api-oauth-2-v1';

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 = require('yaas-api-oauth-2-v1/leagcy.js')

var client = new YaasApiOauth2V1()

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 = new YaasApiOauth2V1({ ... })

client('GET', '/', {
  baseUri: 'https://api.eu.yaas.io/hybris/oauth2/anotherVersion',
  headers: {
    'Content-Type': 'application/json'
  }
})

For dynamic header injection - for example required for non-standard REST services asking for custom authentication token - a provider may be defined:

client = new YaasApiOauth2V1({
  getHeaders: ()=>{ return(this.myToken ? {Authorization: "Bearer " + this.myToken} : {}) }
});

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:

new YaasApiOauth2V1({
  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.

client.revoke.post([body, [options]]).then(...)

authorize.get([query, [options]])

Starts the authorization procedure with the parameters specified in the URL query.

client.authorize.get([query, [options]]).then(...)

authorize.post([body, [options]])

This starts the authorization procedure with the parameters specified in the request body (form parameters).

client.authorize.post([body, [options]]).then(...)

token.post([body, [options]])

Use only ONE of the authorization types:

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'
client.token.post([body, [options]]).then(...)

userinfo.get([query, [options]])

Returns claims about the authenticated end user.

client.userinfo.get([query, [options]]).then(...)

userinfo.post([body, [options]])

Returns claims about the authenticated end user.

client.userinfo.post([body, [options]]).then(...)

tokeninfo.get([query, [options]])

When the query parameters access_token is provided, this endpoint returns tenant, scopes, allowedServices, etc. associated with the access token.

client.tokeninfo.get([query, [options]]).then(...)

License

Apache 2.0