Skip to content

Authentication

Deva Kumar edited this page Apr 27, 2022 · 7 revisions

Authentication

viya-appserverjs can be used in the following modes:

  1. As a web server for static assets with no authentication

  2. With authentication

    • Implicit flow authentication
    • Coming soon: authorization_code authentication

No authentication

Your env file will look something like this:

APPLOC=./public
APPENTRY=index.html
...other settings...

Authorization_code flow

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...

Implicit Flow

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]
        }
    }
Clone this wiki locally