1

I want to implement annotateit (http://annotateit.org) on my website and enable logged in members to annotate certain texts using delegated authentication. annotateit website and GitHub provide some tutorials and docs for this but they are very vague and I just can't fathom most of it. I want to setup a php page which creates a token for my logged in user so that they don't have to have their own account with annotateit.org. There is a python .py example but I'm only able to script php. I'd appreciate some pointers on how to create a toekn generator using php so that my logged in users can annotate texts and save them via annotateit store.

I hope I've made some sense here! thanks

  • Can you show us what you did first? StackOverflow is a website where we can help you along and point out your mistakes, not tell you want to do or do it for you. – ElectronicGeek May 04 '14 at 21:30
  • Well, I've installed the scripts and got them working. I've created an account with annotateit and can now load a page of text which is annotateable by anyone with an annotateit account. But there is nowhere that demonstrates how to implement a php token generator script so that I can allow logged in users to annotate. I know I am just reiterating what I said in my first post but there is nothing in the docs to demonstrate a token generator in php. I know you're not here to do it for me. I just need a few pointers. I don't want to be spoon-fed. Just asking for a little and/or guidance. – user3602324 May 04 '14 at 22:18
  • Can you point me to the pages in the docs that mention how to do delegated authentication!! I am trying the same but I am not able to find the doc pages for that purpose. – faizan Feb 07 '17 at 11:48

1 Answers1

0

The php equivalent of their example is:

<php
public function getToken(){
       $token = array(
        'consumerKey' => $_ENV['CONSUMER_KEY'],
        'userId'      => Auth::user()->id,
        'issuedAt'    => date('Y-m-d\TH:i:s').'Z',
        'ttl'         => $_ENV['CONSUMER_TTL'],
       );
       $consumer_secret = $_ENV['CONSUMER_SECRET'];

       $jwt = JWT::encode($token, $consumer_secret);

       return json_encode($jwt); 
}
?>

JWT can be pulled in with composer using:

"firebase/php-jwt": "~1.0"

(other packages can be found at http://jwt.io/) and the $_ENV variables are your tokens generated by annotateit. That said I'm still getting "didn't get valid token" errors that I cant resolve.

jclyons52
  • 306
  • 3
  • 8