Search code examples
.netopenstackrackspace-cloud

Authenticating restricted user to Cloud Files on Rackspace using openstack.net


On Rackspace cloud management portal, I created a user that has access to only Cloud Files service and when I login to the portal with this user everything works fine. The account is only given access to the files tab as expected. And I can create/view/delete files from the UI.

But I cannot authenticate this user in my code using openstack.net library. I try the same with my primary user and the authentication works fine in my code. But using the primary users API key in the application is not an option due to security concerns.

            var identity =
            new CloudIdentity()
            {
                Username = "username",
                APIKey = "apikey",
            };

            var storage = new CloudFilesProvider(identity);

            storage.CreateObject("sitefiles", inputStream, fileName);

I get the exception "The user does not have access to the requested service or region"


Solution

  • Well, I faced the same problem however I provided username, apikey, password but it didn't work !. I figured out that you should specify a region so the user can access it. like :

            var identity =
            new CloudIdentity()
            {
                Username = "username",
                APIKey = "apikey",
            };
    
            var storage = new CloudFilesProvider(identity);
    
            storage.CreateObject("sitefiles", inputStream, fileName, region: "LON");
    

    Try it and it will work.