Skip to main content

login()

Zuora

login()

The login() call takes a user name and a password and logs you in to the Zuora server. This SOAP API reference includes syntax, call wrappers and container descriptions, requirements, and examples.

Usage

Use this call to log in to the Zuora server. The call returns a session ID, which you then use for subsequent calls for authenticating with the system.

Although you can log in, you cannot explicitly log out. The session timeout for any given login session is defined by the Session timeout value configured in the Security Policies administration setting. The default setting is 15 minutes.

See Log in to the SOAP API for more information about this call.

Syntax and Arguments

login(username, password, entityId, entityName)

The arguments must be specified in the following order: username, password, entityId, entityName. If you reverse the order, then you receive the following error: Unexpected subelement username/password/entityId/entityName

Argument Description
username The login name of the entity user who is logging in.
password The password for that entity user.
entityId

(Optional) The Id of the entity that you want to access. Note that you must have permission to access the entity. You can get the entity Id through the REST GET Entities call.

This argument is only used for Zuora Multi-entity.

You can specify either the entityId or entityName argument in the login call to access and view an entity.

  • If both entityId and entityName are specified in the login call, an error occurs.
  • If neither entityId nor entityName is specified in the login call, you will log in to the entity in which your user account is created. 

See API User Authentication for more information.

entityName

(Optional) The name of the entity that you want to access. Note that you must have permission to access the entity. You can get the entity name through the REST GET Entities call.

This argument is only used for Zuora Multi-entity

You can specify either the entityId or entityName argument in the login call to access and view an entity.

  • If both entityId and entityName are specified in the login call, an error occurs.
  • If neither entityId nor entityName is specified in the login call, you will log in to the entity in which your user account is created. 

See API User Authentication for more information.

Response

LoginResult

Sample Code

Login login = new Login();
login.setUsername("username@company.com");
login.setPassword("password");

LoginResponse resp = stub.login(login);
LoginResult result = resp.getResult();

// set new endpoint
ServiceClient client = stub._getServiceClient();
client.getOptions().getTo().setAddress(result.getServerUrl());

// create session for all subsequent calls
SessionHeader header = new SessionHeader();
header.setSession(result.getSession());
 

Sample Request

<!-- sample login call -->
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://object.api.zuora.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://api.zuora.com/">
    <SOAP-ENV:Body>
        <ns1:login>
            <ns1:username>username@zuora.com</ns1:username>
            <ns1:password>password</ns1:password>
        </ns1:login>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Sample Response

<!-- sample login response -->
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <ns1:loginResponse xmlns:ns1="http://api.zuora.com/">
            <ns1:result>
                <ns1:Session>LiUBQF...ugxg2jJuCA==</ns1:Session>
                <ns1:ServerUrl>https://apisandbox.zuora.com/apps/services/a/26.0</ns1:ServerUrl>
            </ns1:result>
        </ns1:loginResponse>
    </soapenv:Body>
</soapenv:Envelope>

Sample Subsequent API Calls

<!-- sample API query -->
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://object.api.zuora.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://api.zuora.com/">
    <SOAP-ENV:Header>
        <ns1:SessionHeader>
            <ns1:session>LiUBQF...ugxg2jJuCA==</ns1:session>
        </ns1:SessionHeader>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:query>
            <ns1:queryString>select id from account</ns1:queryString>
        </ns1:query>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Sample Code for Multi-entity

Login login = new Login();
login.setUsername("username@company.com");
login.setPassword("password");
login.setentityId("6337");

LoginResponse resp = stub.login(login);
LoginResult result = resp.getResult();

// set new endpoint
ServiceClient client = stub._getServiceClient();
client.getOptions().getTo().setAddress(result.getServerUrl());

// create session for all subsequent calls
SessionHeader header = new SessionHeader();
header.setSession(result.getSession()); 

Sample Request

<!-- sample login call -->
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://object.api.zuora.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://api.zuora.com/">
    <SOAP-ENV:Body>
        <ns1:login>
            <ns1:username>username@zuora.com</ns1:username>
            <ns1:password>password</ns1:password>
            <ns1:entityId>6337</ns1:entityId>
        </ns1:login>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Sample Response

<!-- sample login response -->
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
        <ns1:loginResponse xmlns:ns1="http://api.zuora.com/">
            <ns1:result>
                <ns1:Session>LiUBQF...ugxg2jJuCA==</ns1:Session>
                <ns1:ServerUrl>https://apisandbox.zuora.com/apps/services/a/26.0</ns1:ServerUrl>
            </ns1:result>
        </ns1:loginResponse>
    </soapenv:Body>
</soapenv:Envelope>

Sample Subsequent API Calls

<!-- sample API query -->
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://object.api.zuora.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://api.zuora.com/">
    <SOAP-ENV:Header>
        <ns1:SessionHeader>
            <ns1:session>LiUBQF...ugxg2jJuCA==</ns1:session>
        </ns1:SessionHeader>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:query>
            <ns1:queryString>select id from account</ns1:queryString>
        </ns1:query>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>