Seaside, JWT and REST

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Seaside, JWT and REST

SebastianHC
Hi!

I have a working JWT (JsonWebToken) protected Zinc based REST server.
I do also have a Seaside server as a user platform.

Now I would like to integrate some results of the REST interfaces of the
Zinc based server into my seaside frontend.
How would I define an ajax call including a JWT token in Seaside that
populates a table rendered by seaside on/after page load?

Thank you for any ideas!
Sebastian
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside, JWT and REST

SebastianHC
Okay,

I found some information that would at least give me a chance to not add
additional load to my seaside server.
But unfortunately I can not find any documentation on the "ajax
beforeSend" topic in Seaside's history.

How do I implement the "beforeSend" part of this script in Seaside?

<script type='text/javascript'>
// define vars
var url = 'https://...';

// ajax call
$.ajax({
     url: url,
     dataType : 'jsonp',
     beforeSend : function(xhr) {
       // set header if JWT is set
       if ($window.sessionStorage.token) {
           xhr.setRequestHeader("Authorization", "Bearer " +
$window.sessionStorage.token);
       }

     },
     error : function() {
       // error handler
     },
     success: function(data) {
         // success handler
     }
});
</script>


Thank you!
Sebastian




Am 21.10.2015 um 11:26 schrieb Sebastian Heidbrink:

> Hi!
>
> I have a working JWT (JsonWebToken) protected Zinc based REST server.
> I do also have a Seaside server as a user platform.
>
> Now I would like to integrate some results of the REST interfaces of
> the Zinc based server into my seaside frontend.
> How would I define an ajax call including a JWT token in Seaside that
> populates a table rendered by seaside on/after page load?
>
> Thank you for any ideas!
> Sebastian
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside, JWT and REST

Paul DeBruicker
There is the JQAjaxSetup>>#onBeforeSend: method and you'd use it like:


html anchor
       url:'javascript(0);',
       onClick: (html jQuery ajax
                                  callback: [self processCallBack];
                                  onBeforeSend:(JSStream on: ('if ($window.sessionStorage.token) {
           xhr.setRequestHeader("Authorization", "Bearer " +
$window.sessionStorage.token);} ' asFunction: #('xhr')));
       with: 'do the thing'.


Beware that's in email client code so may not work exactly but you get the gist of it I think.


SebastianHC wrote
Okay,

I found some information that would at least give me a chance to not add
additional load to my seaside server.
But unfortunately I can not find any documentation on the "ajax
beforeSend" topic in Seaside's history.

How do I implement the "beforeSend" part of this script in Seaside?

<script type='text/javascript'> // define vars var url = 'https://...'; // ajax call $.ajax({ url: url, dataType : 'jsonp', beforeSend : function(xhr) { // set header if JWT is set if ($window.sessionStorage.token) { xhr.setRequestHeader("Authorization", "Bearer " + $window.sessionStorage.token); } }, error : function() { // error handler }, success: function(data) { // success handler } }); </script>

Thank you!
Sebastian




Am 21.10.2015 um 11:26 schrieb Sebastian Heidbrink:
> Hi!
>
> I have a working JWT (JsonWebToken) protected Zinc based REST server.
> I do also have a Seaside server as a user platform.
>
> Now I would like to integrate some results of the REST interfaces of
> the Zinc based server into my seaside frontend.
> How would I define an ajax call including a JWT token in Seaside that
> populates a table rendered by seaside on/after page load?
>
> Thank you for any ideas!
> Sebastian
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: [Bulk] [Seaside] Re: Seaside, JWT and REST

SebastianHC
asFunction: ?!?! That easy? I was expecting a Block fore the whole
onBeforeSend as parameter....

Oh boy! Thank you very much Paul! I will implement my test and then I'll
let the list know if it worked....

Sebastian


Am 21.10.2015 um 13:44 schrieb Paul DeBruicker:

> There is the JQAjaxSetup>>#onBeforeSend: method and you'd use it like:
>
>
> html anchor
>         url:'javascript(0);',
>         onClick: (html jQuery ajax
>                                    callback: [self processCallBack];
>                                    onBeforeSend:(JSStream on: ('if
> ($window.sessionStorage.token) {
>             xhr.setRequestHeader("Authorization", "Bearer " +
> $window.sessionStorage.token);} ' asFunction: #('xhr')));
>         with: 'do the thing'.
>
>
> Beware that's in email client code so may not work exactly but you get the
> gist of it I think.
>
>
>
> SebastianHC wrote
>> Okay,
>>
>> I found some information that would at least give me a chance to not add
>> additional load to my seaside server.
>> But unfortunately I can not find any documentation on the "ajax
>> beforeSend" topic in Seaside's history.
>>
>> How do I implement the "beforeSend" part of this script in Seaside?
>>
>> Thank you!
>> Sebastian
>>
>>
>>
>>
>> Am 21.10.2015 um 11:26 schrieb Sebastian Heidbrink:
>>> Hi!
>>>
>>> I have a working JWT (JsonWebToken) protected Zinc based REST server.
>>> I do also have a Seaside server as a user platform.
>>>
>>> Now I would like to integrate some results of the REST interfaces of
>>> the Zinc based server into my seaside frontend.
>>> How would I define an ajax call including a JWT token in Seaside that
>>> populates a table rendered by seaside on/after page load?
>>>
>>> Thank you for any ideas!
>>> Sebastian
>>> _______________________________________________
>>> seaside mailing list
>>>
>> seaside@.squeakfoundation
>>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>>>
>> _______________________________________________
>> seaside mailing list
>> seaside@.squeakfoundation
>> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>
>
>
> --
> View this message in context: http://forum.world.st/Seaside-JWT-and-REST-tp4857137p4857153.html
> Sent from the Seaside General mailing list archive at Nabble.com.
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside