How to use .Net API to access SWIFT?

Asked by csxbwang

After setting up virtual encironment for swift development, I want to use .net api access swift.

following codes get 401 error
Connection = new Connection(new UserCredentials(new Uri("http://192.168.1.102:11000/v1.0"), "test:tester", "testing", null, null, null));

from syslog got:

Aug 20 00:01:53 csxbwang-ubuntu auth 192.168.1.101 - - [19/Aug/2010:16:01:53 +0000] "GET /v1.0 HTTP/1.0" 401 - "-" "csharp-cloudfiles" - - - - - - - - - "-" "192.168.1.101" "-" 0.0002

Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Object Storage (swift) Edit question
Assignee:
No assignee Edit question
Solved by:
csxbwang
Solved:
Last query:
Last reply:
Revision history for this message
gholt (gholt) said :
#1

I'm not very familiar with the .NET API, but what you have looks right, and you're hitting the auth server if you see that log line in syslog. Are you sure that account is set up correctly? Try running this sqlite3 command on the server running auth:

$ sqlite3 /etc/swift/auth.db 'select user, password from account where account = "test"'

And make sure it outputs:

tester|testing

Revision history for this message
csxbwang (xbwang-zh) said :
#2

thanks. I solved the problem. It is an encoding problem, 'test:tester' -->'test%3atester'.

Revision history for this message
Ryan (r-jones1) said :
#3

How were you able to resolve the encoding issue? I've encountered the same problem.

Thanks!

Revision history for this message
csxbwang (xbwang-zh) said :
#4

GetAuthentication.cs

public void Apply(ICloudFilesRequest request)
        {
            request.Method = "GET";
    // request.Headers.Add(Constants.X_AUTH_USER, _userCredentials.Username.Encode());

            request.Headers.Add(Constants.X_AUTH_USER, _userCredentials.Username);

              request.Headers.Add(Constants.X_AUTH_KEY, _userCredentials.Api_access_key.Encode());
        }

> To: <email address hidden>
> From: <email address hidden>
> Subject: Re: [Question #121868]: How to use .Net API to access SWIFT?
> Date: Wed, 13 Oct 2010 18:53:07 +0000
>
> Your question #121868 on OpenStack Object Storage (swift) changed:
> https://answers.launchpad.net/swift/+question/121868
>
> Ryan Jones posted a new comment:
> How were you able to resolve the encoding issue? I've encountered the
> same problem.
>
> Thanks!
>
> --
> You received this question notification because you are a direct
> subscriber of the question.

Revision history for this message
Kevin Atwood (atwood-kevin) said :
#5

Anyone else had to modify Connection.cs near 1591:

From:
//if (getAuthenticationResponse.Status == HttpStatusCode.NoContent)

To:
if (getAuthenticationResponse.Status == HttpStatusCode.OK)