Newbie Question

Kieron Moran's Avatar

Kieron Moran

04 Nov, 2012 04:38 PM

Hello,

I would like to create a .net integration and would like to know how to format the web request with the api key and password.

At present, all I get is the rather annoying 401 Unauthorized.

Any pointers or sample .net code would be great.

Thanks in advance,

Kieron

  1. Support Staff 2 Posted by Glen on 04 Nov, 2012 08:14 PM

    Glen's Avatar

    Hi Kieron,

    Thanks for reaching out. The Handshake API uses HTTP Basic Authentication (as described at http://en.wikipedia.org/wiki/Basic_access_authentication) in the same format as the 37 Signals APIs.

    We do not use .NET internally here, so I won't be able to provide you with any .NET sample code, but most frameworks provide some kind of library for putting basic auth headers on a HTTP request.

    If not, the Python code below should help illuminate how to form the HTTP header that our API ultimately expects to be on your request:

    # We use api key as username, dummy 'x' as password
    apiKey = "abcd1234abcd1234"
    userAndPass = apiKey + ":x"
    
    # HTTP basic auth must be encoded to base 64
    encodedUserAndPass = userAndPass.encode( "base64" )
    httpAuthHeader = "Authorization: Basic " + encodedUserAndPass
    

    Hope that helps!

  2. Glen closed this discussion on 04 Nov, 2012 08:15 PM.

  3. Kieron Moran re-opened this discussion on 04 Nov, 2012 10:17 PM

  4. 3 Posted by Kieron Moran on 04 Nov, 2012 10:17 PM

    Kieron Moran's Avatar

    Hi Glen,

    Thats an awesome answer. Thanks very much.

    It was the base64 encoding I failed on :-(

    Kieron

  5. Mike closed this discussion on 05 Nov, 2012 05:50 PM.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

01 Feb, 2013 01:09 AM
31 Jan, 2013 10:20 PM
31 Jan, 2013 07:21 PM
25 Nov, 2012 01:57 AM
30 Jan, 2013 06:56 PM