Database cant be written to after removing an API key

28 views
Skip to first unread message

Alex Neuman

unread,
Jul 27, 2015, 6:22:04 AM7/27/15
to RavenDB - 2nd generation document database

Hi,

We had an issue with one of our databases because of which we had to delete and recreate the database. We couldn't figure out how to provide our own API ( the one in use before recreating the database). So we didn't create any API key at all for our database. But now we can't access the database from our client applications.

We are using build #2945


If we don't provide any API key in connection string, this is the exception/stack trace that we get

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.
   at System.Net.HttpWebRequest.GetResponse()
   at Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(Func`1 getResponse)
   at Raven.Client.Connection.HttpJsonRequest.ReadResponseJson()
   at Raven.Client.Connection.ServerClient.DirectBatch(IEnumerable`1 commandDatas, OperationMetadata operationMetadata)
   at Raven.Client.Connection.ReplicationInformer.TryOperation[T](Func`2 operation, OperationMetadata operationMetadata, OperationMetadata primaryOperationMetadata, Boolean avoidThrowing, T& result, Boolean& wasTimeout)
   at Raven.Client.Connection.ReplicationInformer.ExecuteWithReplication[T](String method, String primaryUrl, OperationCredentials primaryCredentials, Int32 currentRequest, Int32 currentReadStripingBase, Func`2 operation)
   at Raven.Client.Connection.ServerClient.ExecuteWithReplication[T](String method, Func`2 operation)
   at Raven.Client.Document.DocumentSession.SaveChanges()

In the raven configuration file, we have given admin access to anonymous.

Can you tell why are we getting 403 error?

On a side note: How can add edit the API key so that I can paste own 'secret' in the API key. I want to use an API key that we generated earlier as that is the key that we have communicated to all our consumers.

Regards,
Alex

Oren Eini (Ayende Rahien)

unread,
Jul 27, 2015, 6:36:33 AM7/27/15
to ravendb
You can't access the db because you have to use an API key.
And you can edit the secret in the API key generation screen.

I'm not sure that I'm following on your issue here.

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.

Alex Neuman

unread,
Jul 27, 2015, 6:51:27 AM7/27/15
to RavenDB - 2nd generation document database, aye...@ayende.com
Hi

Right now, the database doesn't have an API key set so I shouldn't be using API in my connection string. 

Even if I use an API in connection string, I get  a 403 - Unauthorized error, with following stack trace

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
   at System.Net.HttpWebRequest.GetResponse()
   at Raven.Abstractions.OAuth.SecuredAuthenticator.DoOAuthRequest(String oauthSource, String apiKey)
   at Raven.Client.Connection.HttpJsonRequest.HandleUnauthorizedResponse(HttpWebResponse unauthorizedResponse)
   at Raven.Client.Connection.HttpJsonRequest.ReadResponseJson()
   at Raven.Client.Connection.ServerClient.DirectBatch(IEnumerable`1 commandDatas, OperationMetadata operationMetadata)
   at Raven.Client.Connection.ReplicationInformer.TryOperation[T](Func`2 operation, OperationMetadata operationMetadata, OperationMetadata primaryOperationMetadata, Boolean avoidThrowing, T& result, Boolean& wasTimeout)
   at Raven.Client.Connection.ReplicationInformer.ExecuteWithReplication[T](String method, String primaryUrl, OperationCredentials primaryCredentials, Int32 currentRequest, Int32 currentReadStripingBase, Func`2 operation)
   at Raven.Client.Connection.ServerClient.ExecuteWithReplication[T](String method, Func`2 operation)
   at Raven.Client.Document.DocumentSession.SaveChanges()


It seems that database has some kind of API key set, however I can't see in Studio. Do you have the same opinion after looking at both stack traces?

Regards,
Alex

Oren Eini (Ayende Rahien)

unread,
Jul 27, 2015, 8:07:04 AM7/27/15
to Alex Neuman, RavenDB - 2nd generation document database
That isn't how it works. 
If you don't have API key setup, you won't be able to access the db.

You have to explicitly grant permission to access, we don't implicitly grant permissions.

Alex Neuman

unread,
Jul 27, 2015, 8:09:08 AM7/27/15
to RavenDB - 2nd generation document database, aye...@ayende.com, smart...@gmail.com
I am using build #2945 and I can't seem to edit the secret part of API key.

It seems its not possible to do it in version 3.x either

http://live-test.ravendb.net/studio/index.html#admin/settings/apiKeys

Regards,
Alex

Oren Eini (Ayende Rahien)

unread,
Jul 27, 2015, 8:11:36 AM7/27/15
to Alex Neuman, RavenDB - 2nd generation document database
Go to the Raven/ApiKeys/... document and edit that directly, then.

Hibernating Rhinos Ltd  

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

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

 


Alex Neuman

unread,
Jul 27, 2015, 9:59:58 AM7/27/15
to RavenDB - 2nd generation document database, aye...@ayende.com
Hello,

Adding the API did the trick.

Thanks!
Reply all
Reply to author
Forward
0 new messages