Coder Social home page Coder Social logo

identity-toolkit-php's Introduction

This is the PHP client library for Google Identity Toolkit services.

Sample usage
=====================

require_once __DIR__ . '/vendor/autoload.php';

$jsonConfig = json_decode(file_get_contents("gitkit-server-config.json"), true);
$gitkitClient = new Gitkit_Client($jsonConfig);

// ---- upload account -----
$hashKey = "\x01\x02\x03";
$gitkitClient->uploadUsers('HMAC_SHA1', $hashKey, createNewUsers($hashKey));

// --- verify gitkit token ----
$user = $gitkitClient->validateToken("eyJhb...");

// ---- get account info by user identifier ----
$user = $gitkitClient->getUserById("1234");

// ---- download account ----
$iterator = $gitkitClient->getAllUsers(3);
while ($iterator->valid()) {
  $user = $iterator->current();
  // $user is a Gitkit_Account object
  $iterator->next();
}

// ---- delete account ----
$gitkitClient->deleteUser('1234');

function createNewUsers($hashKey) {
  $allUsers = array();

  $gitkitUser = new Gitkit_Account();
  $gitkitUser->setEmail("[email protected]");
  $gitkitUser->setUserId("1234");
  $salt = "\05\06\07";
  $password = '1111';
  $gitkitUser->setSalt($salt);
  $gitkitUser->setPasswordHash(hash_hmac('sha1', $password . $salt, $hashKey, true));
  array_push($allUsers, $gitkitUser);

  $gitkitUser = new Gitkit_Account();
  $gitkitUser->setEmail('[email protected]');
  $gitkitUser->setUserId('5678');
  $salt = "\15\16\17";
  $password = '5555';
  $gitkitUser->setSalt($salt);
  $gitkitUser->setPasswordHash(hash_hmac('sha1', $password . $salt, $hashKey, true));
  array_push($allUsers, $gitkitUser);

  return $allUsers;
}

identity-toolkit-php's People

Contributors

jdgreenberg avatar jin-liu avatar liujin-google avatar mcduan avatar

Stargazers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

identity-toolkit-php's Issues

Out of date packages name and version

"gitkit/apiclient" => "google/identity-toolkit-php-client" (1.0.1 fixed a serious error)
"google/apiclient" => 1.1.* now

Why included silex and twig? This is just a sample for Identity Toolkit, too much redundant codes?

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.