-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Datastore: Client requires authentication even when connecting to the datastore emulator #11
Comments
@rylz Thanks for the report! See also #4840 . |
The problem is still open, because with some code like this: client_kwargs = {}
if settings.DEBUG:
import requests
client_kwargs.update({
"project": settings.PROJECT_ID,
"_http": requests.Session(),
})
client = datastore.Client(**client_kwargs) (note that I had to pass the
This is happening because somehow the resulted credentials (which is Is there any way of running Datastore emulator within dev_appserver.py using standard python3.7 runtime and being able to store an entity? I'm using a similar environment as described above. Thanks! |
@rylz Are you still facing the issue with latest release. I tried to connect to datastore emulator using AnonymousCredentials and its working for me. Here is the steps i followed and sample code:
OS : Win7 x64 Sample Code from google.cloud import datastore
from google.auth.credentials import AnonymousCredentials
client = datastore.Client(
project="emulated-project",
namespace='ns_test',
credentials=AnonymousCredentials(),
_http=None
)
print ("Adding a entity in datastore....")
pdf = datastore.Entity(client.key('PDF'))
pdf.update({'path': 'asd'})
client.put(pdf)
print ("Success..") |
@sumit-ql I figured it out pretty much the same time as you did. I think in addition to your sample code, there are two required arguments in the |
Closing this issue, because it has been resolved. feel free to reopen if needed! |
I'm experiencing this issue with It only works with In addition to that I found I needed to export |
I would, but lack privileges to do so. |
@c4rlo Cloud you please share Here are the steps:
from google.cloud import datastore
from google.auth.credentials import AnonymousCredentials
client = datastore.Client(
project="emulated-project",
namespace='ns_test',
credentials=AnonymousCredentials(),
_http=None
) |
In addition to passing an instance of /path/to/venv/bin/pip install google-test-utils from google.cloud import datastore
from test_utils.system import EmulatorCreds
client = datastore.Client(
project="emulated-project",
namespace='ns_test',
credentials=EmulatorCreds(),
_http=None
) |
I use As I mentioned, when explicitly passing However, I don't see a requirement for that documented anywhere. It's not mentioned either in the emulator docs or in the Moreover, why should this even be necessary? As the original comment in this issue said:
|
@c4rlo For emulator you can use |
Ok, However, that was not really the main issue. The main issue is the need to pass And if there is a good reason for this, then why is the need for this not documented anywhere? |
@c4rlo I think it's new feature request to set at @tseaver Your view on this, |
When I try to construct a datastore client on a box that has the datastore emulator enabled and running, I get the following:
However, it's clear that these credentials are not actually required because when I initialize my client as follows, it works in both dev and production:
With that change, the library works fine for me, but this seems like something the library ought to be able to detect and handle by default to save devs a lot of time.
In case they're relevant:
python --version
pip show google-cloud
,pip show google-<service>
orpip freeze
The text was updated successfully, but these errors were encountered: