Git Product home page Git Product logo

identity-toolkit-node-client's Introduction

Google Identity Toolkit client library for Node.js

Sample usage

Initialize Gitkit client instance

  var GitkitClient = require('gitkitclient');
  var gitkitClient = new GitkitClient({
    'clientId' : GOOGLE_OAUTH2_WEB_CLIENT_ID,
    'serviceAccountEmail' : SERVICE_ACCOUNT_EMAIL@developer.gserviceaccount.com,
    'serviceAccountPrivateKeyFile' : PRIVATE_KEY_IN_PEM_FORMAT.pem,
    'widgetUrl' : 'http://localhost:8000/gitkit',
    'cookieName' : 'gtoken'
  });

Verify Gitkit Token string

  gitkitClient.verifyGitkitToken(tokenString, function (err, parsedToken) {
    console.log('login user is', parsedToken);
  });

Upload Multiple Accounts

  var hashKey = new Buffer('key123');
  var hashOptions = {
    'hashAlgorithm': 'HMAC_SHA1',
    'hashKey': hashKey
  };
  function createNewUsers(hashKey) {
    var crypto = require('crypto');
    var user1 = {
      localId: '1234',
      email: '[email protected]',
      salt: new Buffer('salt-1'),
      passwordHash: crypto.createHmac('SHA1', hashKey).update('1111' + 'salt-1').digest()
    };
    return [user1];
  }
  gitkitClient.uploadAccount(createNewUsers(hashKey), hashOptions, function (err, resp){
    if (err) {
      console.log('error: ', err);
    } else {
      console.log(resp);
    }
  });

Download Accounts

  gitkitClient.downloadAccount(10, function(err, accounts){
    if (err) {
      console.log('error: ', err);
    } else {
      if (accounts != null) {
        console.log(accounts);
      } else {
        console.log('finished');
      }
    }
  });

Get Account Info

  gitkitClient.getAccountByEmail("[email protected]", function(err, resp) {
    console.log('getAccountByEmail: ', err, resp);
  });
  gitkitClient.getAccountById("1234", function(err, resp) {
    console.log('getAccountById: ', err, resp);
  });

Get the URL to verify user's email

  gitkitClient.getEmailVerificationLink("[email protected]", function(err, resp) {
    console.log('email verification link: ' + resp);
  });

Delete Account

  gitkitClient.deleteAccount('1234', function(err, response){
    if (err) {
      console.log("error: ", err);
    } else {
      console.log(response);
    }
  });

identity-toolkit-node-client's People

Contributors

liujin-google avatar phated avatar qiqihu avatar wuyanna avatar wyhao31 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

identity-toolkit-node-client's Issues

getAccountByEmail not working

I tried in gitkitclient 0.0.7 getAccountByEmail but it keeps failing with with this error:

{ [Error: email is required.] code: 'MISSING_CREDENTIALS' }

Depricated dependencies

When I install this package I get the following warnings:

npm WARN deprecated [email protected]: Security update: Versions below 3.0.0 are deprecated.
npm WARN deprecated [email protected]: This module is not supported. Please use 'tap' instead.
npm WARN installMany tap-consumer was bundled with [email protected], but bundled package wasn't found in unpacked tree
npm WARN deprecated [email protected]: This module is not supported. Please use 'tap' instead.

Is it possible to update to a newer version of googleapis? This package uses version 1.0.0, the newest one is 2.1.5

Cannot verify the Token generated via iOS SDKs.

I'm following this doc to verify the token on the backend using this package. The token is generated via iOS SDK. I'm not sure how the secret is composed via the credentials I've provided to iOS SDKs, to generate the token, but I've generated .pem anyways to decode and verify the token for the backend. It fails with the following error Unable to verify the ID Token: No pem found for envelope: {"alg":"RS256","kid":"ad8070377cc099d874672776dfx.xxxxxxxx"}.

Are Service Account Email and Private Key File necessary?

I'm using the identity toolkit to verify tokens, but I've removed the serviceAccountEmail and serviceAccountPrivateKeyFile fields in my gitkit.server.config.js file and the identity toolkit sign in still works. Do I actual need to include the serviceAccountEmail and serviceAccountPrivateKeyFile fields?

This is my gitkit.server.config.js:

const widgetHost = process.env.APP_HOST || 'localhost:8000';

let config = {
  clientId: '*************',
  projectId: '***********',
  widgetUrl: `http://${widgetHost}/gitkit`,
  cookieName: 'gtoken'
};

export default config;

Cannot verify the key

It's very hard to use correctly at the first time, any product from Google.

I receive this error:

Invalid token: Unable to verify the ID Token: Wrong recipient, payload audience != requiredAudience.

I follow the Quick-start App for Node.js to implement the demo application. I do it two time, but it does not work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.