1

What are recommended best practices for reusing the OAuth token for the ExactTarget Fuel SDK?

On my website once I get a valid OAuth token, I cache it for 15 minutes and use that same token for all requests. Are there any possible pitfalls to this approach? My website is made up of two web servers. Is the authenticated token based on IP at all?

Instantiate ET_Client:

$params = array("clientid" => $this->getClientId(),
                    "clientsecret" => $this->getClientSecret(),
                    "xmlloc" => 'ExactTarget'.DS.'FuelSDK'.DS.'ExactTargetWSDL.xml' );
$this->_client = new ET_Client(false, false, $params);

Response Object: the instantiated ET_Client returns a tenantToken with a DateTime authTokenExpiration property that is 20 minutes from the request time.

["tenantTokens":"ET_Client":private]=>
  array(1) {
    [""]=>
    array(4) {
      ["authToken"]=>
      string(24) "..."
      ["authTokenExpiration"]=>
      object(DateTime)#628 (3) {
        ["date"]=>
        string(19) "2015-03-06 10:26:36"
        ["timezone_type"]=>
        int(3)
        ["timezone"]=>
        string(3) "UTC"
      }
      ["internalAuthToken"]=>
      string(257) "..."
      ["refreshToken"]=>
      string(24) "..."
    }
  }

1 Answer 1

0

The token will expire after an hour from the time it is issued. It's best to use it that long before requesting another. Every 15 minutes will work, but requesting a token with every operation could result in throttling of your website. Correct, no other IP addresses will be able to use your token.

5
  • Thanks @Drew, I'll make sure each server has its own cached token. And regarding the 1 hr token expiration: my returned ET_Client authentication token has an authTokenExpiration DateTime object that is only 20 minutes from my request time, which is why I went with refreshing every 15 minutes. Is this configurable anywhere?
    – Peggy C
    Commented Mar 4, 2015 at 6:42
  • My guess is that the 20 minutes you saw was the time remaining for the original token. Commented Mar 4, 2015 at 14:54
  • Actually that was the response from getting a brand new token (no caching).
    – Peggy C
    Commented Mar 4, 2015 at 17:19
  • Can you include the request and response in your question? Are you able to duplicate it? Commented Mar 4, 2015 at 17:26
  • Yes I'm able to duplicate it every time. Included my calling code and the token object that is returned. Did not include the full ET_Client object - only the token property that included the expiration datetime object.
    – Peggy C
    Commented Mar 6, 2015 at 10:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .