-
Notifications
You must be signed in to change notification settings - Fork 2
Authentication
Deva Kumar edited this page Apr 27, 2022
·
7 revisions
viya-appserverjs can be used in the following modes:
-
As a web server for static assets with no authentication
-
With authentication
- Implicit flow authentication
- Coming soon: authorization_code authentication
Your env file will look something like this:
APPLOC=./public
APPENTRY=index.html
...other settings...
This is the recommended flow.
Create a clientid and clientsecret with authorization_code flow. Make sure that the redirect is set to
{APPHOST}:{APPPORT}/{APPNAME}
Examples
http://localhost:5000/viyaapp
https://mymachine:433/viyaapp
The env file will look as follows:
AUTHFLOW=code
CLIENTID=someclientid
CLIENTSECRET=someclientsecret
...other settings...
Set the redirect as follows:
{APPHOST}:{APPPORT}/{APPNAME}/callback
Examples:
http://localhost:5000/viyaapp/callback
https://mymachine:433/viyaapp/callback
Then env file will look as follows:
AUTHFLOW=implicit
CLIENTSECRET=
CLIENTID=someclientsecret
...other settings...
In your index.html parse the url to obtain the token and Viya host url. Below is a simple example of parsing the url.
function parseUrl(){
let hash = window.location.hash;
let qa = hash.split('&');
return {
tokenType: qa[0].split('=')[1],
token : qa[1].split('=')[1],
host : window.location.search.split('=')[1]
}
}