Integrating AngularJS with Cuba - Best practices


I need to integrate a Cuba REST API with an Angular Application.

I have created a REST API using cuba in web module. To integrate it with an Angular JS application what is recommended ? Create a Portal module like described here: [url=][/url] or should I put the Angular application inside the web module directly ?

The generation of the OAuth token and its putting on http request headers are done automatically by Cuba or do I have do set something in the Angular application ?

Thanks in advance


It’s not required to place your Angular application along with CUBA application. Portal Module is just an option.
All client applications should obtain an OAuth token by themselves and then use it for all future RESP API requests. A token can be obtained by the POST request on the address:


The detailed documentation for the API is written according to Swagger specification and is available at the following URL: [url=][/url].
You can find REST API usage examples in the documentation.
Alternatively, you can access REST API without an OAuth token using Anonymous Access.
To simplify developers’ life we have JavaScript library for web and Node.js which facilitates CUBA Platform’s REST API usage. Check its GitHub page.
Also, we’re going to provide a webinar in which we will show how to develop a single-page web application with REST API backend using Angular 4.
You can overview upcoming webinars here.

Thank you for your detailed response Gleb.

Could you tell me where in this application GitHub - cuba-platform/sample-portal: Example of a portal implemented using AngularJS

the http://localhost:8080/app/rest/v2/oauth/token is used ?



Actually, referred sample is quite outdated and uses REST API v1 in which there is no oauth token and session_id is used instead.