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 🙏

© 2026 – Pkg Stats / Ryan Hefner

snap-oauth-2

v1.0.39

Published

![Digital Identity on Blockchain](https://auth.snapxplatform.com/images/logo.svg)

Readme

#SnapX-OAuth-2.0

Digital Identity on Blockchain

##Introduction SnapX-Oauth-2.0 lets users grant the access to the desired resources to third party applications (Job-Portal, rental services etc.), giving them the possibility to enable and disable those accesses whenever they want.

Requirements

The node client library is tested against the latest Node 8 LTS and newer versions.

To use in node 6 or 7, please use [email protected]. Older node versions are unsupported.

Getting started

Installation

Install the client library using npm:

npm install --save snap-oauth-2

Define a object of snapX class

// Initialize the snap-oauth-2 Library and set configuration
const snapX = require("snap-oauth-2");
const snapXObject = new snapX(
  "<client-id>",
  "<client-secret>",
  "<redirectUri)>"
);

Example of Usage

we will update it soon

##SnapX-Oauth-2.0 Authorization Code flow

  • The Authorization Code flow is made up from two parts. At first your application(client) asks to the user for the permission to access their data. If the user approves, then SnapX-Oauth-2.0 server sends an authorization code to the client. In the second part, the client POST the authorization code along with its client secret to the SnapX-Oauth-2.0 server in order to get the access token along with refresh token.

  • After getting access token client can retreive resource owner's (user) information from resource server or calling specific api for that.

  • Access Token is generated by Snapx-Oauth-server will only be valid for given time so for renewal of access token client will need refresh token (received in previous step inside tokenObject) so calling refresh token api client will receive a new tokenObject and previously generated tokens (both refresh and access toke ) will be expired !

const snapX = require("snap-oauth-2");
const snapXObject = new snapX(
  '<client-id>',
  '<client-secret>',
  '<redirectUri)>'
);

###To get access token using authorization code (received from SnapX-Oauth-2.0 server)

    snapXObject.getAccessToken(authorization_code).then(tokenObject => {
     //here you have tokenObject
  } catch((error)=>{
    //handle error from Oauth server
  })

###To get userdata using accessToken ( received from SnapX-Oauth server )

snapXObject
  .getUserInfo(access_token)
  .then(userInfo => {
    // here is user's data
  })
  .catch(error => {
    //handle error from server
  });

###To get userdata using authorization_code directly (received from SnapX-Oauth server)

snapXObject
  .getUserData(grantCode)
  .then(userData => {
    // here is user's data
  })
  .catch(error => {
    //handle error from server
  });

###To renew access token using refresh token (received from SnapX-Oauth server)

snapXObject
  .renewAccessToken(refresh_token)
  .then(tokenObject => {
    // here is user's data
  })
  .catch(error => {
    //handle error from server
  });

TokenObject format

tokenObject = {
  access_token: {
    value: '<access_token>',
    refresh_token: '<refresh_token>',
    expires_in: '<expiry time in millisecods>',
  },
  token_type: "bearer",
};

Grant code generated by Snapx-Oauth-2 server after user consent will be valid for one time use only after using it for once, it will be expired.