.net Oauth Authentication Issues

Discussion in 'Shapeways API' started by shiawniu, Mar 11, 2017.

  1. shiawniu
    shiawniu Member
    I am trying the .net example. I updated the ConsumerKey and ConsumerSecret, but when I run the example, I got following error.
    {"result":"failure","reason":"Authentication Error"}

    Can someone please help?
  2. stonysmith
    stonysmith Well-Known Member Moderator
    Try setting the content type...
  3. imdaveho
    imdaveho Shapeways Employee Product Team
    @shiawniu If you can provide a snippet of what you're trying to run either here or with this form bit.ly/api-issues-form, we can help you triage the issue.

    But @stonysmith is correct in part---try setting the ContentType header to application/json (not x-www-form-urlencoded)

    If that doesn't work, the issues form or code snippet would help us help you :D
  4. shiawniu
    shiawniu Member

    I am just running the .net example from ShapeWays.

    This is the URL that return the error {"result":"failure","reason":"Authentication Error"}. I used my own consumer key.


    Please let me know if more information needed.
  5. imdaveho
    imdaveho Shapeways Employee Product Team
    @shiawniu the parameters need to be part of the Authorization header:

    Authorization: OAuth oauth_consumer_key="MY_CONSUMER_KEY",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1489437518",oauth_nonce="hs2t1uQd0CN",oauth_version="1.0",oauth_signature="Iim6a0oaXvhvFf16jg6lI8aIIzI%3D"

    Just tested. When I request with URI params, I get the same error as you. To spec, you need to pass through Authorization Header.
  6. shiawniu
    shiawniu Member
    @imdaveho, Thanks for the information, I added some screenshots. I thought I included the header already.


  7. imdaveho
    imdaveho Shapeways Employee Product Team
    request.Headers.Add("Authorization", "OAuth oauth_consumer_key='YOUR+CONSUMER_KEY',oauth_signature_method='HMAC-SHA1',oauth_timestamp='1489437518',oauth_nonce='hs2t1uQd0CN',oauth_version='1.0',oauth_signature='SIGNATURE'")

    It seems you're just appending the auth credentials and appending it to the URL (lines 42 and 43). You need to attach the params to the request.Headers similar to these examples and NOT in the URL:

  8. shiawniu
    shiawniu Member
    wow, it's working, thanks a lot.
  9. Abhijithz
    Abhijithz Member
    Im using the postman to check the api, and im facing the same issue authentication error

    I belive i have problem with generated oauth signature, How do i generate the oauth signature

    Attached Files: