pycontribs / pyrax

The Python SDK for the Rackspace Cloud
developer.rackspace.com
Apache License 2.0
237 stars 208 forks source link

Authentication error using configuration file #555

Closed larry-s closed 9 years ago

larry-s commented 9 years ago

I am getting an error authenticating using a configuration file.

I set up a configuration file as described in https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#authenticating then I run

python

import pyrax pyrax.set_http_debug(True) pyrax.set_setting("identity_type", "rackspace") pyrax.set_credential_file("~/.pyrax")

This shows: REQ: curl -i -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' https://identity.api.rackspacecloud.com/v2.0/tokens REQ BODY: {'auth': {'passwordCredentials': {'username': 'username', 'password': 'api_key'}, 'tenantId': 'username'}}

If I use set_credentials it works correctly:

python

import pyrax pyrax.set_http_debug(True) pyrax.set_setting("identity_type", "rackspace") pyrax.set_credentials("username", "api_key")

I get: REQ: curl -i -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' https://identity.api.rackspacecloud.com/v2.0/tokens REQ BODY: {'auth': {'RAX-KSKEY:apiKeyCredentials': {'username': 'username', 'apiKey': 'api_key'}}}

larry-s commented 9 years ago

I had a spelling mistake. It does try the passwordCredentials, but only after the apiKeyCredentials have failed.

annegentle commented 9 years ago

Okay good to know! I just tested myself with ~/ and found I had to add the full path on a Mac, so that was going to be my next guess, that it wasn't correctly interpreting the tilde (~). Thanks for replying and closing.