Authentication Error, Prob With Oauth_signature

Discussion in 'Shapeways API' started by Abhijithz, Mar 15, 2017.

  1. Abhijithz
    Abhijithz New Member
    Hi,

    I have seen through the previous posts, i am trying to get access token so that i will be able to upload new models, i'm having error with the following request throwing authentication error.

    Im using the postman to check the api, and im facing the same issue authentication error

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

    How can i identify the where is the problem.
     

    Attached Files:

  2. imdaveho
    imdaveho Shapeways Employee Product Team
    @Abhijithz with Postman, you can head over to Authorization and choose OAuth 1.0. Insert the information there.

    What programming language are you using? Basically there are OAuth 1.0a libraries that does the encryption (signing) and formats the Authorization Header properly; which looks something like this:

    Authorization OAuth oauth_consumer_key=CONSUMER_KEY, oauth_signature_method="HMAC-SHA1", oauth_timestamp="1489594144", oauth_nonce="aVLGLNfCOf8", oauth_version="1.0", oauth_signature=SIGNATURE

    That's for the request_token/v1 endpoint. If that is a success, Shapeways will send you back an authorization URL, with a temporary oauth_token and oauth_token_secret which you will copy+paste into the browser (make sure to change the %2F and %3F to / and : respectively)

    Then you can login and authorize the client and get back a Verifier Code

    With the verifier, you can call /access_token/v1 with the oauth_token, oauth_token_secret + consumer_key and consumer_secret for the signature. Once that is complete, you should get your access token and secret.

    NOTE: if you just screenshotted an img with your consumer key and secret in that img, I recommend that you reset your credentials immediately.
     
  3. Abhijithz
    Abhijithz New Member
    Hi imdaveho,

    Your reply actually helped, still i'm i'm having problem.

    I'm Using ruby language and oauth gem is installed this is the command i used

    @consumer = OAuth::Consumer.new("key","secret", :site => "http://api.shapeways.com", :request_token_path => "/oauth1/request_token/v1", :http_method => :get)

    @request_token = @consumer.get_request_token

    and i got the authentication_url like you mentioned. and i visited the url in the browser and i authenticated the app, and got the verifier code

    Now i tried

    @request_token.get_access_token => gives me authentication error(OAuth::Unauthorized: 401 Unauthorized)

    Even i have checked the example provided by shapeways, it asks for access_token before even we got one
     
  4. imdaveho
    imdaveho Shapeways Employee Product Team
  5. Abhijithz
    Abhijithz New Member
    Hi @imdaveho ,

    I have checked the authorize ruby file in the example also the first part is ok, i have modified and got the result it says

    @consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {:site=>url})

    i changed it to

    @consumer = OAuth::Consumer.new("key","secret", :site => "http://api.shapeways.com", :request_token_path => "/oauth1/request_token/v1", access_token_path => "/oauth1/access_token/v1", :http_method => :get)
    @request_token = @consumer.get_request_token

    the second part i was not able to change since oauth token and secret i havent got

    @accesstoken = OAuth::AccessToken.new(@consumer, access_token, access_secret) # this is from example

    So i checked the methods from @request_token -> get_access_token was present and then i gave

    @request_token.get_access_token and i got 401 unauthorized,

    I also checked the docs i'm having the same problem with this endpoint /oauth1/access_token/v1 unauthorized