Update to 0.0.7
Google Identity Toolkit client library for Node.js
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' });
gitkitClient.verifyGitkitToken(tokenString, function (err, parsedToken) { console.log('login user is', parsedToken); });
var hashKey = new Buffer('key123'); var hashOptions = { 'hashAlgorithm': 'HMAC_SHA1', 'hashKey': hashKey }; function createNewUsers(hashKey) { var crypto = require('crypto'); var user1 = { localId: '1234', email: '1234@example.com', 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); } });
gitkitClient.downloadAccount(10, function(err, accounts){ if (err) { console.log('error: ', err); } else { if (accounts != null) { console.log(accounts); } else { console.log('finished'); } } });
gitkitClient.getAccountByEmail("1234@example.com", function(err, resp) { console.log('getAccountByEmail: ', err, resp); }); gitkitClient.getAccountById("1234", function(err, resp) { console.log('getAccountById: ', err, resp); });
gitkitClient.getEmailVerificationLink("1234@example.com", function(err, resp) { console.log('email verification link: ' + resp); });
gitkitClient.deleteAccount('1234', function(err, response){ if (err) { console.log("error: ", err); } else { console.log(response); } });
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802047560号
Google Identity Toolkit client library for Node.js
Sample usage
Initialize Gitkit client instance
Verify Gitkit Token string
Upload Multiple Accounts
Download Accounts
Get Account Info
Get the URL to verify user’s email
Delete Account