1

I am using the php-opencloud / Rackspace SDK.

I only have one user connecting to the API, which is the entire site that is running.

By default it will make an authentication request before every API call, which is of course crazy.

I want to simply cache the token (I'm thinking apc_add() / apc_fetch()) and then pass it in next time to prevent that extra API call. There will be one token for the whole site so this makes sense to me.

This is what I have but it's not recognising the data and it just keeps making the extra API call in line 2 anyway.

What am I doing wrong? How would I simply pass in a token to stop it making authentication API calls?

// uses https://github.com/rackspace/php-opencloud

$client->importCredentials(array('token'=>'the-token', 'expiration'=>'2014-03-01T01:02:09.384Z', 'tenant'=>'xxxxxxxx'));    

$queue = $client->queuesService('cloudQueues', 'LON', 'internalURL')->setClientId();
user2143356
  • 5,467
  • 19
  • 51
  • 95
  • Which version are you using? It looks like until 3 months ago, the X-Auth-Token wasn't getting set: https://github.com/rackspace/php-opencloud/issues/236 – JRP Feb 28 '14 at 17:22
  • Thanks a lot, but this hasn't solved it. I'm using the very latest version, and it does have the changes shown in the post you linked to. Something else must be wrong. – user2143356 Feb 28 '14 at 18:00
  • Just to clarify, you've implemented caching similar to here: https://github.com/rackspace/php-opencloud/blob/master/docs/userguide/caching-credentials.md , but via APC. Are you including 'catalog' when importing your credentials? – JRP Feb 28 '14 at 20:49
  • Great, solved, thanks. I didn't see that part of the docs, and implemented caching myself. Now, I just store the result of exportCredentials() and pass it in using importCredentials(). Thanks. – user2143356 Feb 28 '14 at 23:09
  • Cool. Collated below for other's reference. – JRP Mar 03 '14 at 15:46

1 Answers1

2

When you implement caching, you'll want to use exportCredentials. If not, you'll manually have to make sure you have all the fields correctly set (namely, token, expiration, tenant, and catalog).

Kyle Kelley
  • 13,804
  • 8
  • 49
  • 78
JRP
  • 979
  • 6
  • 9