How to get rest access token from UserSession

Hi everyone! I know the same thing were discussed before at How do I get current user access token?, but I have a bit different problem.
I have a custom application which connected with my CUBA-application through Rest-Api.
Also a custom application put in my CUBA - application through component - browserFrame.
Well can I get an access token and send it to my custom application?

The same problem here. Got an js application form.io that is integrated as cuba component in another cuba application. This js app sends file to a standard rest api file storage (to url like http://localhost:8080/app/rest/v2/files , that uses standart method, taken from 4.2 https://doc.cuba-platform.com/restapi-7.1/#rest_api_v2_ex_file_upload). But rest api requires an authorization with rest user credentials to obtain a bearer token to get access to. Js app is integrated in cuba screen, so there is an active user session avaliable. How can I make rest resourse to take this user session to get access to uploading file for js app to upload the file?