Skip to main content

zlogin Method

Zuora

zlogin Method

The zlogin() method uses the Zuora  login() method to log into the Zuora server. You must invoke the zlogin() method on an instantiated zApi class before calling any other methods on that class.

You must configure an endpoint before calling the zlogin(). Use one of the following methods:

If the endpoint has been configured, you can use the no-argument login method. Otherwise, you can explicitly specify the endpoint and username and password.

Syntax

The following versions of the zlogin() method are supported. If username and password are not given, the values in the connection setting pages are used.

  • Zuora.zApi.LoginResult zlogin ()
  • Zuora.zApi.LoginResult zlogin (String entityId)​
  • Zuora.zApi.LoginResult ​zlogin (String username, String password)
  • Zuora.zApi.LoginResult zlogin (String username, String password, String entityId)

Parameters

The zlogin() method takes the following parameters.

Parameter Type Description
username String Zuora API Username
password String Zuora API Password in plain text
entityId String Id of the Zuora entity

Response

The zlogin() method returns a Zuora.zApi.LoginResult class.

zApi.LoginResult

The zApi.LoginResult has the following properties.

Property Type Description
ServerUrl String The URL to redirect to for all subsequent API calls.
Session String The authentication token returned during the login process The session token contains information that confirms that the user making an API request is authenticated. 

Exceptions

The zlogin() method throws an exception if there is an error. The following classes are used to catch the exception:

  • zAPIException
  • zForceException
  • zRemoteException

Sample Code

Zuora.zApi zApiInstance = new Zuora.zApi();
try {
zApiInstance.setEndpoint('https://apisandbox-zforsf.zuora.com/apps/services/a/35.0');
zApiInstance.zlogin('test@acme.com', 'test');
} catch (Zuora.zRemoteException ex) {
if ('INVALID_LOGIN' == ex.code) {
// The login credentials are invalid.
}
//more exception handling code here...
} catch (Zuora.zAPIException ex) {
ex.getMessage();
//more exception handling code here...
} catch (Zuora.zForceException ex) {
//more exception handling code here...
}