Oauth2 and best authorization technique for webix

Hi,

We are building system, and we are going to have the same REST API for native mobile clients and for website full build on Webix UI.

We are thinking of implementing Oauth2 for native clients, and for Webix, if possible, but we are not sure.

What is the best authorization technique for Webix?
Is there any link for best authorization practices in Webix?
Is Oauth2 suitable for Webix?

Advices are appreciated. Thank you.

Hi,

Webix is a javascript library, so you can treat it the same as any other js library, there are no any special rules or limitations.

You can use Oauth2 with Js apps in common, and that means you can use Oauth2 with Webix.

Check for example
https://developers.google.com/+/web/signin/javascript-flow

Thanks, will check that.

Hello All, I have another question about the Oauth.
@skaos : are you able to implement the Oauth client on your webix apps?

Because I need to make my apps like skaos mention above. But I still didn’t get how to implement it. My main concern is : how do we attach the access_token for every request to server? Mostly is when implement the datatable dynamic. Can you please give us the exact example (@maksim) ?

how do we attach the access_token for every request to server

You can use onBeforeAjax event to add custom headers for all ajax requests.

webix.attachEvent("onBeforeAjax", function(mode, url, params, x, headers){
   headers["mytoken"] = myvalue;
});

I will answer my last question by self btw. The problem is because of the CORS security that I need to setup on server side. Now it works.

Hi @maksim, you are so nice.
Actually I have problem when try to edit my header.
When I add a header like you told, the method of the request becomes “OPTIONS” (should be “GET”) and it caused error because I don’t have such method router on my server.

hi, how to implement attachEvent onBeforeAjax in the webix-jet?

how to implement attachEvent onBeforeAjax

It works the same. Webix Jet allows to organize views, but it doesn’t change the core function of Webix. You can define the custom onBeforeAjax handler in the app.js

webix.attachEvent("onBeforeAjax", handler);

It is not recommended to define this handler from the view, as the handler is a global one, and defining it for one view can cause some problems for other ajax consumers.