Rest API call with API Key Powershell

823 views
Skip to first unread message

Alok Agarwal

unread,
Nov 19, 2015, 12:12:45 PM11/19/15
to RavenDB - 2nd generation document database
Hi,

I am using Ravendb Build 2945. I am trying to do some Rest API calls with API Keys using powershell.

$header = @{"Api-Key"="readwrite/6G7pH37G8";"grant_type"="client_credentials"}
Invoke-RestMethod -Uri "http://master.raven.com/databases/dbname/docs/" -Method Get -Headers $header -Verbose

I get 401 - unauthorised.
Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.

Am I doing something wrong?

Same command works with without authentication enabled.

Thanks.

 

Chris Marisic

unread,
Nov 19, 2015, 1:11:24 PM11/19/15
to RavenDB - 2nd generation document database
Do you have a license with raven? developer mode (ie on your computer) does not allow authentication it is public by default 

Alok Agarwal

unread,
Nov 19, 2015, 1:20:07 PM11/19/15
to RavenDB - 2nd generation document database
Yes, I am on the one of our environment which is licensed and that is why its locked.  

Chris Marisic

unread,
Nov 19, 2015, 1:32:51 PM11/19/15
to RavenDB - 2nd generation document database
Are you connecting with a system-apikey to a regular db? or are you connecting with a regular db apikey to the system db?

Also make sure you destroy that key as you've exposed it to the internet.

Alok Agarwal

unread,
Nov 19, 2015, 2:07:14 PM11/19/15
to RavenDB - 2nd generation document database
These keys are not real. I have changed the keys and URL before posting the query. Thanks for raising it.

I am connecting regular db with the key has permission to tanentid : *

Oren Eini (Ayende Rahien)

unread,
Nov 20, 2015, 3:08:07 AM11/20/15
to ravendb
API Keys are never sent over the wire in this manner.
Instead, you have to ping the oauth token endpoint, and exchange a bunch of requests to generate a token, which is what you'll use to authenticate yourself.
The manner in which this is done is fairly complex, you are better off using either windows auth or calling the ravendb client api to handle this.

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alok Agarwal

unread,
Nov 20, 2015, 3:58:22 AM11/20/15
to RavenDB - 2nd generation document database
Do you have any example where I can refer to. Any Rest API call with API keys (curl or powershell or any other)  

Oren Eini (Ayende Rahien)

unread,
Nov 20, 2015, 4:16:39 AM11/20/15
to ravendb
You can't do that with curl.
We do public key encryption to handle this, and that is too complex to handle easily via shell commands.
Reply all
Reply to author
Forward
0 new messages