Curl request works: URL says not authenticated

98 views
Skip to first unread message

mar...@bluerocket.us

unread,
Apr 28, 2017, 2:06:26 PM4/28/17
to Assembla API Development
Hello there, 

I am attempting to request some data from the Assembla API programmatically.

When I run the following CURL command, I am able to have the correct data returned to me in the terminal.

curl -H "X-Api-Key: my_key" -H "X-Api-Secret: my_secret" https://api.assembla.com/v1/user/mentions.json


However, when I try to hit that same endpoint from my backend using the URL below, I get <response is: {"error"=>"invalid_auth", "error_description"=>"Please provide authentication data (API key/secret pair or a valid access token)"}>

https://my_key: my_secret@api.assembla.com/v1/user/mentions.json


Am I missing something?  I believe I am following the syntax in the assembla api docs.  


Thanks, 


Marcel 





Stanislav Kolotinskiy

unread,
Apr 28, 2017, 2:48:44 PM4/28/17
to mar...@bluerocket.us, Assembla API Development
Hi Marcel,

you can’t pass credentials via Basic auth - the only way to use API key/secret is via headers. So basically you can’t perform API requests using a plain browser. Hope this makes things clearer.

Regards,
Stanislav
 
-- 
You received this message because you are subscribed to the Google Groups "Assembla API Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to assembla-api-d...@googlegroups.com.
To post to this group, send email to assembla...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mar...@bluerocket.us

unread,
Apr 28, 2017, 2:50:24 PM4/28/17
to Assembla API Development
Update:

This is a RoR project and I am using Postman for my HTTP requests.  I tried using key/secret syntax below (a variation of this SO post: http://stackoverflow.com/questions/7627419/how-to-use-basic-authentication-with-httparty-in-a-rails-app ), and I am getting the same error: {"error"=>"invalid_auth", "error_description"=>"Please provide authentication data (API key/secret pair or a valid access token)"}


auth = {'X-Api-Key': '_my_key', 
      'X-Api-Secret': '_my_secret'}
 
response = HTTParty.get('https://api.assembla.com/v1/user/mentions.json', :basic_auth => auth )

mar...@bluerocket.us

unread,
Apr 28, 2017, 3:12:55 PM4/28/17
to Assembla API Development, mar...@bluerocket.us
Hey Stanislav, 

Thanks for your response.  I solved the issue by passing the auth credentials in the header by using the following syntax.  

headers = { 'X-Api-Key': '_my_key', 
'X-Api-Secret': '_my_secret'}
response = HTTParty.get(
:headers => headers
)

Thanks for your help! 

Cheers, 

Marcel


On Friday, April 28, 2017 at 11:48:44 AM UTC-7, Stanislav Kolotinskiy wrote:
Hi Marcel,

you can’t pass credentials via Basic auth - the only way to use API key/secret is via headers. So basically you can’t perform API requests using a plain browser. Hope this makes things clearer.

Regards,
Stanislav
On Apr 28, 2017, at 21:06, mar...@bluerocket.us wrote:

Hello there, 

I am attempting to request some data from the Assembla API programmatically.

When I run the following CURL command, I am able to have the correct data returned to me in the terminal.
curl -H "X-Api-Key: my_key" -H "X-Api-Secret: my_secret" https://api.assembla.com/v1/user/mentions.json

However, when I try to hit that same endpoint from my backend using the URL below, I get <response is: {"error"=>"invalid_auth", "error_description"=>"Please provide authentication data (API key/secret pair or a valid access token)"}>


Am I missing something?  I believe I am following the syntax in the assembla api docs.  

Thanks, 

Marcel 


-- 
You received this message because you are subscribed to the Google Groups "Assembla API Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to assembla-api-dev+unsub...@googlegroups.com.

Stanislav Kolotinskiy

unread,
Apr 29, 2017, 4:59:56 PM4/29/17
to mar...@bluerocket.us, Assembla API Development
Yep, exactly, glad to know that it worked. Have a nice day!

Regards,
Stanislav

To unsubscribe from this group and stop receiving emails from it, send an email to assembla-api-d...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages