Skip to content

First pass at Authentication summary in docs. #830

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

Closed
wants to merge 1 commit into from

Conversation

jgeewax
Copy link
Contributor

@jgeewax jgeewax commented Apr 15, 2015

Took a crack at this, related to #805

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 15, 2015
@jgeewax jgeewax added docs auth and removed cla: yes This human has signed the Contributor License Agreement. labels Apr 15, 2015
@jgeewax jgeewax added this to the Core Stable milestone Apr 15, 2015
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 8b60160 on jgeewax:authentication into 6283ab9 on GoogleCloudPlatform:master.

@jgeewax jgeewax added the cla: yes This human has signed the Contributor License Agreement. label Apr 15, 2015
@jgeewax
Copy link
Contributor Author

jgeewax commented Apr 15, 2015

@tmatsuo : FYI, feedback welcome.

Order of evaluation
-------------------

``gcloud`` will look in a bunch of different places

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

Summary
=======

For the majority of cases,

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 4d6fc98 on jgeewax:authentication into 6283ab9 on GoogleCloudPlatform:master.

authentication should "just work"
as credentials can be loaded implicitly
based on the environment you're application is running in
and therefore there is no extra code required to authenticate.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 5a88b2f on jgeewax:authentication into * on GoogleCloudPlatform:master*.

@jgeewax
Copy link
Contributor Author

jgeewax commented Apr 16, 2015

@dhermes can you take a look?

from gcloud import pubsub

# Create the credentials from the keyfile and set the default connection.
credentials = get_for_service_account_json('/path/to/key.json')

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 0c9c31f on jgeewax:authentication into 286207b on GoogleCloudPlatform:master.

the easiest way to authenticate is using the Cloud SDK.

**If you're running your application elsewhere**,
you should download the service account JSON keyfile

This comment was marked as spam.

This comment was marked as spam.

(and add the answer to your question here).

.. _Google Developers Console: https://console.developers.google.com/project
.. _Credentials: https://pantheon.corp.google.com/project/_/apiui/credential

This comment was marked as spam.

This comment was marked as spam.

@tmatsuo
Copy link
Contributor

tmatsuo commented Apr 23, 2015

I came up with a little concern about thread safety and multiprocessing safety.

Is the implicit method thread safe?
Also, trickier thing is that, even if your client object is thread safe, it could break with multiprocessing.

For example, when I did the following, the apiary client object breaks:

  1. create a client
  2. issue an API call in the main process
  3. fork sharing the client
  4. issue an API with the shared client in the child process

BTW the document looks great now :)

@dhermes
Copy link
Contributor

dhermes commented Apr 27, 2015

@tmatsuo Thanks for pointing this out. I've also worried about how our implicit code would work in a multithreaded environment. (Easy becomes hard very quickly.)


Are you referring to our library or google-api-python-client? Also, can you send sample code and stacktraces if it is us breaking.

@tmatsuo
Copy link
Contributor

tmatsuo commented Apr 27, 2015

@dhermes That's the apiary client, so yes, it was google-api-python-client. However, if you're using httplib2.Http object, it could happen to anyone I guess.

Unfortunately I lost the stacktraces now, I tried to reproduce it, but now I'm failing to repro.
Basically what I did was

  • store the apiary client object in a thread local variable
  • use that client in the main process
  • fork with multiprocessing (thus the client object is copied to the child)
  • use the client in the child process

Then it threw some kind of SSL handshake error.

I will update here once I can reproduce it.

@dhermes
Copy link
Contributor

dhermes commented Apr 27, 2015

Thanks. That's "good news" for us since we don't do config with httplib2 (we use raw httplib / http.client to check compute engine for config).

The flipside is that this could be a larger issue in a threaded environment. I thought I filed an issue about enabling a "bring your own http" but couldn't track it down. (We don't necessarily need to pigeonhole people into using httplib2.)

This means that you can set your credentials a bunch of different ways.
We recommend using some form of implicitly discovered credentials
(ie, set in an environment variable or auto-discovered in GCE/GAE)
so that youre code can be

This comment was marked as spam.

This comment was marked as spam.

@dhermes
Copy link
Contributor

dhermes commented Apr 29, 2015

FYI @jgeewax @tseaver et al I just discovered a quick way to expand all outdated comments:

$(".outdated-diff-comment-container").addClass("open")

from the JS console

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling b18bcff on jgeewax:authentication into 286207b on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling ac9479f on jgeewax:authentication into 73a341c on GoogleCloudPlatform:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 4d6d9f2 on jgeewax:authentication into 73a341c on GoogleCloudPlatform:master.

@dhermes
Copy link
Contributor

dhermes commented Jun 26, 2015

@jgeewax I just tried to revisit this and #805, but realized it's not worth moving forward on until the client pattern is fully in.

When I do move forward on it, I'm going to start with a tiny document (i.e. one paragraph) and then "launch and iterate" so we don't have so many comments to address in a single PR.

@dhermes
Copy link
Contributor

dhermes commented Jun 26, 2015

Though you may notice that this little review spawned #950 and #951.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants