[annotator-dev] Using store plugin: Authentication problem

Panagiotis Papadakos papadako at gmail.com
Fri Jul 31 10:23:44 UTC 2015


Dear Benhamin, thanks for the reply.

Unfortunately I still have not found the problem with authentication.
If I log in  to annotateit and use tokenUrl: '
http://annotateit.org/api/token'
to the Auth plugin, everything works fine. So something is wrong with the
token
I create or annotateit store itself.

When I started writing the code for the token I was getting warning messages
that the token was invalid, probably because I was not providing all needed
information. Now I do not get such messages, so I assume that the token is
valid. Since the key, userId etc are correct, I am not sure what is left to
check. Maybe annotate.it does not work as expected? I am not sure I would
like
at this point deploy my own annotation store...

Additionally, another problem that I think exists is that if you add
autoFetch: true, sometimes there are multiple requests to get a token,
which has already been reported again in the related to my problem thread
https://lists.okfn.org/pipermail/annotator-dev/2014-March/000847.html

Best regards
Panagiotis

On Thu, Jul 30, 2015 at 7:40 PM, Benjamin Young <bigbluehat at hypothes.is>
wrote:

> On Thu, Jul 30, 2015 at 11:03 AM, Panagiotis Papadakos <papadako at gmail.com
> > wrote:
>
>> Well it seems that there was some problem with the jquery version.
>> I was using 1.11.3 and by reverting to jquery 1.8.3 I got a more
>> reasonable error message.
>>
>
> It'd be great to get your input on this issue (which you're welcome to
> reopen):
> https://github.com/openannotation/annotator/issues/429
>
> Apparently others have had time with jQuery 1.11.x, so knowing newer
> information on the problem would be helpful.
>
>
>>
>> Specifically now I get an 401 unauthorized error, so probably something
>> is wrong with the token I create. I load the auth plugin before the Store
>> plugin,
>> so I guess this is not an ordering problem.
>>
>> "NetworkError: 401 UNAUTHORIZED - http://annotateit.org/api/annotations"
>> annotations
>> API request failed: '401'
>>
>
> This does sound like a token problem (possibly) or some other auth /
> permissions related thing. Not sure what to suggest here, other than more
> digging. :-P
>
> Others may know more, hopefully.
>
> Thanks for being here!
> Benjamin
> --
> Developer Advocate
> http://hypothes.is/
>
>
>>
>> On Thu, Jul 30, 2015 at 3:53 PM, Panagiotis Papadakos <papadako at gmail.com
>> > wrote:
>>
>>> Hello everyone
>>>
>>> I am new to annotator.js, so probably this is a pretty naive question.
>>>
>>> I want to use annotate.it as a backend for my annotations. I have
>>> created
>>> an account for it and dynamically create tokens using the jjwt library
>>> with
>>> the following code, where CONSUMER_KEY is the annotateit key for my
>>> account, CONSUMER_SECRET is the corr. secret and  CONSUMER_TTL
>>> is set to 86400 (one day).
>>>
>>> String getToken() {
>>>     // Use time for expiration
>>>     TimeZone tz = TimeZone.getTimeZone("UTC");
>>>     DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
>>>     df.setTimeZone(tz);
>>>     String nowAsISO = df.format(new Date());
>>>
>>>     Claims claims = Jwts.claims().setId(UUID.randomUUID().toString()) //
>>> uuid
>>>         .setIssuer("http://www.ics.forth.gr/isl/LifeWatchAnnotation")
>>>         .setAudience("http://www.annotateit.org");
>>>
>>>         claims.put("consumerKey", CONSUMER_KEY);// consumer key
>>>         claims.put("userId", "myid");       // account Id for annotateit
>>>         claims.put("issuedAt", nowAsISO);       // time as ISO8601
>>>         claims.put("ttl", CONSUMER_TTL);        // expire in seconds
>>> (one day)
>>>
>>>     // Now create the token
>>>     String token = Jwts.builder()
>>>         .setClaims(claims) // Add the necessary claims for annotateit
>>>         .signWith(SignatureAlgorithm.HS256,
>>>         CONSUMER_SECRET).compact();
>>>
>>>     return token;
>>> }
>>>
>>> So up to here I think my token is valid as I have checked in
>>> http://jwt.io/
>>>
>>> But unfortunately, when I add the store plugin in my js code, that uses
>>> the
>>> aforementioned token through the Auth plugin, I get the following error
>>>
>>> API request failed: '0' in annotator-full.min.js (line 17)
>>>
>>> Do you have any idea about what might be wrong?
>>>
>>> Thank you and best regards
>>>
>>> Panagiotis
>>>
>>>
>>
>>
>> --
>> http://www.flickr.com/photos/papadako
>>
>> _______________________________________________
>> annotator-dev mailing list
>> annotator-dev at lists.okfn.org
>> https://lists.okfn.org/mailman/listinfo/annotator-dev
>> Unsubscribe: https://lists.okfn.org/mailman/options/annotator-dev
>>
>>
>


-- 
http://www.flickr.com/photos/papadako
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20150731/839ed6d6/attachment-0004.html>


More information about the annotator-dev mailing list