forio Toggle navigation

Authentication API Service

The Authentication API Service provides a method for logging in, which creates and returns a user access token.

User access tokens are required for each call to Epicenter. (See Project Access for more information.)

If you need additional functionality -- such as tracking session information, easily retrieving the user token, or getting the groups to which an end user belongs -- consider using the Authorization Manager instead.

 var auth = new F.service.Auth();
 auth.login({ userName: 'jsmith@acmesimulations.com',
             password: 'passw0rd' });

Constructor options

Required? Name Type Description
Yes userName string Email or username to use for logging in.
  account string The account id. In the Epicenter UI, this is the Team ID (for team projects) or User ID (for personal projects). Defaults to undefined. If left undefined, taken from the URL.
  project string The project id. Defaults to undefined. If left undefined, parsed from the URL.
  token string For projects that require authentication, pass in the user access token (defaults to undefined). If the user is already logged in to Epicenter, the user access token is already set in a cookie and automatically loaded from there. (See more background on access tokens). @see Authentication API Service for getting tokens.
  transport JQueryAjaxOptions Options to pass on to the underlying transport layer. All jquery.ajax options are supported.
  server object
  server.host string The value of host is usually the string api.forio.com, the URI of the Forio API server. This is automatically set, but you can pass it explicitly if desired. It is most commonly used for clarity when you are hosting an Epicenter project on your own server
  server.protocol https / http Defaults to https

Methods

login([options])

Logs user in, returning the user access token.

If no userName or password were provided in the initial configuration options, they are required in the options here. If no account was provided in the initial configuration options and the userName is for an end user, the account is required as well.

Parameters

Required? Name Type Description
  options Object Overrides for configuration options.

Example

auth.login({
    userName: 'jsmith',
    password: 'passw0rd',
    account: 'acme-simulations' })
.then(function (token) {
    console.log("user access token is: ", token.access_token);
});