Thank you for visiting the Rackspace Community
The Community is live! Post new content or topics so our teams can assist.

Please contact your support team if you have a question or need assistance for any Rackspace products, services, or articles.

Getting Authentication Error from Rackspace

This question is answered.

I am creating a service layer in my project to save file into Rackspace. I keep getting this error:

Unable to authenticate user and retrieve authorized service endpoints

Not sure how to fix it. The sources I am following are:

https://github.com/openstacknetsdk/openstack.net/wiki/Rackspace-Cloud-Files-Code-Samples

Rackspace Cloud Files Get Objects In Container C#

Here is my code

       public bool CreateAndAddFiles()
        {
            try
            {
                var user = new CloudIdentityWithProject()
                {
                    Username = UserName,
                    APIKey = ApiKey
                };
           var cloudIdP = new CloudIdentityProvider(user,new Uri(RaSUrl));
           var cloudProvider = new CloudFilesProvider(cloudIdP);
           var cloudProvider = new CloudFilesProvider(cloudIdP);
           ObjectStore createSomething = cloudProvider.CreateContainer("TestContainer");
           cloudProvider.CreateObjectFromFile("TestContainer", @"C:\some\attachment(1)", "test");
           }
           catch(Exception ex)
             {
              _log.Error(ex.message, ex);
              throw;
             }
           }

http://www.openstacknetsdk.org/docs/html/1bb35d97-0c79-4e98-a2ae-6c1eef098ba7.htm

Openstack.Net SDK cannot access services

After going through the above two links, I made one change i.e changing the cloudIdP variable to OpenStackIdentityProvider type. That did not work either as it requires me to add my password.

Could anyone point out what I am missing?

Also a question on how to store ApiKey and UserName. I have implemented these as app setting values in my app.config and comes through ConfigurationManager. Has any one done it differently? I am not comfortable exposing it this way.

Verified Answer
  • We've hashed this out over email and discovered that this was due to incorrect RBAC user permissions. Below is the code used to test out permissions to cloud files:

    using net.openstack.Core.Domain;
    using net.openstack.Providers.Rackspace;
     
    namespace AuthenticateRackspace
    {
        class Program
        {
            static void Main()
            {
                var user = new CloudIdentity
                {
                    Username = "username",
                    APIKey = "apikey"
                };
                var cloudFiles = new CloudFilesProvider(user);
                var containers = cloudFiles.ListContainers();
            }
        }
    }
All Replies
  • We are experiencing the exact same issue.    Our call to this API works 80-90% of the time and then the other 10-20% it does not and we receive the following error below. 

    Error Message: net.openstack.Core.Exceptions.Response.UserNotAuthorizedException: Unable to authenticate user and retrieve authorized service endpoints

    Could you provide the resolution to us as well?

  • Hi Arhaus,

    Intermittent authentication failures is not something that I have encountered before, and most likely is not the same problem as what was reported in this thread.

    Would you please log a ticket with support and provide any additional details, such as code snippets, how often this happens, which endpoint doesn't work, if you are behind a firewall/proxy, any troubleshooting steps you have tried so far, etc. We will do our best to troubleshoot and identity what's causing the problem that you are experiencing.


    Thanks!
    Carolyn

  • We've hashed this out over email and discovered that this was due to incorrect RBAC user permissions. Below is the code used to test out permissions to cloud files:

    using net.openstack.Core.Domain;
    using net.openstack.Providers.Rackspace;
     
    namespace AuthenticateRackspace
    {
        class Program
        {
            static void Main()
            {
                var user = new CloudIdentity
                {
                    Username = "username",
                    APIKey = "apikey"
                };
                var cloudFiles = new CloudFilesProvider(user);
                var containers = cloudFiles.ListContainers();
            }
        }
    }