Skip to content

Instantly share code, notes, and snippets.

@sjehutch
Created December 20, 2016 22:01
Show Gist options
  • Save sjehutch/215c7a013ccfc5691f664bb52b20de22 to your computer and use it in GitHub Desktop.
Save sjehutch/215c7a013ccfc5691f664bb52b20de22 to your computer and use it in GitHub Desktop.
// 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