login

The login function is used to begin an authenticated API session.

Overview

If the attempt is successful, a sessionId will be returned that should be included as a SOAP header element for all subsequent requests in the session. Sessions will automatically be expired after 20 minutes of inactivity, at which point you will need to call login again.

Syntax

result = bApi.login(apiToken);

Parameters

Name Type Required Description
apiToken string Yes The API token is the unique string that you use to access the API. Tokens are generated inside the Bronto application under Settings > Data Exchange, or via a call to updateAccounts with an account object with an new API token.

PHP Code Example

    /**
     * This script will log you in and generate a session.
     *
     * @copyright  Copyright (c) 2018 Bronto Software
     */
 
    $client = new SoapClient('https://api.bronto.com/v4?wsdl', 
                             array('trace' => 1,'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
 
    try {
 
        // Add your API token
        $token = "ADD YOUR API TOKEN";
 
        $sessionId = $client->login(array('apiToken' => $token))->return;
 
        $session_header = new SoapHeader("http://api.bronto.com/v4",
                                         'sessionHeader',
                                         array('sessionId' => $sessionId));
        $client->__setSoapHeaders(array($session_header));
 
        print "logging in with sessionId: $sessionId\n";
    } catch (Exception $e) {
        print "uncaught exception\n";
        print_r($e);
    }

Python Code Example

      """
      This example script will login to the API and obtain
      a session id.
      @copyright  Copyright (c) 2018 Bronto Software
      """
 
      import sys
      import logging
      from suds.client import Client
      from suds import WebFault
 
      # Bronto API WSDL
      BRONTO_WSDL = 'https://api.bronto.com/v4?wsdl'
 
      # start up basic logging
      logging.basicConfig()
 
      # Replace the placeholder text with a valid
      # API token
      TOKEN = "ADD YOUR API TOKEN"
 
      # login using the token to obtain a session ID
      bApi = Client(BRONTO_WSDL)
      # print bApi
 
      try:
            session_id = bApi.service.login(TOKEN)
            print "logging in with sessionId: " + session_id
      # Just exit if something goes wrong
      except WebFault, e:
         print '\nERROR MESSAGE:'
         print e
         sys.exit()