Git Product home page Git Product logo

identity-toolkit-php-client's Introduction

Google Identity Toolkit client library for PHP

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

Example Code

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

$gitkitClient = Gitkit_Client::createFromFile("gitkit-server-config.json");

// ---- 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");

// ---- get a url to send to user's email address to verify ownership -----
$verificationLink = $gitkitClient->getEmailVerificationLink("[email protected]");

// ---- 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-client's People

Contributors

cslink avatar enteee avatar liujin-google avatar naokigoogle avatar qiqihu avatar redstrike 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

identity-toolkit-php-client's Issues

[Composer] google/apiclient 1.1 is not compatible with google/identity-toolkit-php-client?

Problem 1
  - The requested package google/apiclient could not be found in any version, there may be a typo in the package name.
Problem 2
  - google/identity-toolkit-php-client 1.0.1 requires google/apiclient 1.0.* -> no matching package found.
  - google/identity-toolkit-php-client 1.0.1 requires google/apiclient 1.0.* -> no matching package found.
  - Installation request for google/identity-toolkit-php-client 1.0.1 -> satisfiable by google/identity-toolkit-php-client[1.0.1].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Below my require section in composer.json:

  "require": {
    "google/identity-toolkit-php-client": "^1.0",
    "google/apiclient": "^1.1"
  }

[Question] Forced verify email after password sign up

Does Gitkit has this behaviour built-in on client-side code? Or I have to implement it myself?

After entering the password and finished creating an account, user is redirected to sign_in_success_url, without knowing about verifying email step. So, do we really need to verify email if we use Gitkit's flow?

[BUG] Token used too early

I didn't see this bug before, it has happened last week until now. You could try it at my live demo page: http://m.raphay.com/user/sign_in

Token used too early, 1442487747 < 1442487806:
{  
   "iss":"https://identitytoolkit.google.com/",
   "aud":"176327357454-tv700agv82ggdlujldn205m2i3eprqp8.apps.googleusercontent.com",
   "iat":1442488106,
   "exp":1443697706,
   "user_id":"04296657315607463607",
   "email":"[email protected]",
   "provider_id":"yahoo.com",
   "verified":true,
   "display_name":"Tùng Nguyễn",
   "photo_url":"https://s.yimg.com/dh/ap/social/profile/profile_b48.png"
}

Below is the main source code of /user/sign_in:

$gitkitClient = Gitkit_Client::createFromConfig($config);
$user = null;

try {
    $user = $gitkitClient->getUserInRequest();
} catch (Exception $e) {
    die($e->getMessage());
}

if ($user) {
    echo 'Email: ' . $user->getEmail() . '<br>';
    echo 'Name: ' . $user->getDisplayName() . '<br>';
    echo 'Provider ID: ' . $user->getProviderId() . '<br>';
    echo 'User ID: ' . $user->getUserId() . '<br>';
    echo 'Password Hash: ' . $user->getPasswordHash() . '<br>';
    echo 'Photo URL: ' . $user->getPhotoUrl() . '<br>';
    echo 'Salt: ' . $user->getSalt() . '<br>';
    echo 'Email Verified: ' . $user->isEmailVerified() . '<br>';
    echo '<a href="/user/delete_account">Delete account</a>' . '<br>';
} else {
    echo 'Not logged in.';
}

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.