.net Oauth Authentication Issues

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

  1. 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...
    ContentType:application/x-www-form-urlencoded
     
  3. 1064125_deleted
    1064125_deleted 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. @imdeveho,

    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.

    https://api.shapeways.com/oauth1/request_token/v1?oauth_callback=http://localhost:49314/Callback.aspx&oauth_consumer_key="MyConsumerKey"&oauth_nonce=5sh22mal7t5hg60e&oauth_signature=cBswvVfy6RGhaYLXwTaON0sZbdg%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1489424955&oauth_version=1.0a

    Please let me know if more information needed.
     
  5. 1064125_deleted
    1064125_deleted 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. @imdaveho, Thanks for the information, I added some screenshots. I thought I included the header already.

    upload_2017-3-13_14-1-51.png

    upload_2017-3-13_14-0-36.png
     
  7. 1064125_deleted
    1064125_deleted 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:

    http://stackoverflow.com/questions/4675166/asp-net-http-authorization-header
    http://stackoverflow.com/questions/...uest-to-send-authorization-header-during-post
     
  8. wow, it's working, thanks a lot.
     
  9. 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: