Created
December 20, 2016 22:01
-
-
Save sjehutch/215c7a013ccfc5691f664bb52b20de22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using JWT from PHP requires you to first either install the JWT PEAR package from | |
// http://pear.php.net/pepr/pepr-proposal-show.php?id=688 or get the JWT project | |
// from https://github.com/firebase/php-jwt on GitHub. | |
// mobile app initializes zendesk sdk and passes NS user id to zendesk | |
// NS api webhook would be below (assuming php) | |
<?php | |
include_once "Authentication/JWT.php"; | |
// Log your user in. | |
$key = "{my zendesk shared key}"; | |
$subdomain = "{my zendesk subdomain}"; | |
$now = time(); | |
$token = array( | |
"jti" => md5($now . rand()), | |
"iat" => $now, | |
"name" => $user->name, | |
"email" => $user->email | |
); | |
$jwt = JWT::encode($token, $key); | |
echo json_encode(["token" => $jwt]); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment