Skip to content
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

Adding get_for_service_account_json function in credentials. #641

Merged
merged 2 commits into from
Feb 15, 2015

Conversation

dhermes
Copy link
Contributor

@dhermes dhermes commented Feb 13, 2015

Fixes #638.

@jgeewax PTAL

I thought about wrapping JSON key and PKCS12 key into one method but the JSON key is actual a JSON payload with everything needed, e.g.

{
  "private_key_id": "0996.....",
  "private_key": "-----BEGIN PRIVATE KEY-----\nMIICdgIBADA.....\n-----END PRIVATE KEY-----\n",
  "client_email": "32578400.......@developer.gserviceaccount.com",
  "client_id": "32578400.........apps.googleusercontent.com",
  "type": "service_account"
}

whereas a P12 key is just the bytes in private_key (and created for PKCS12 rather than PEM).

I don't think it's worth trying to smash together the two API surfaces:

get_for_service_account_json(private_key_path, scope=None)
get_for_service_account_p12(client_email, private_key_path, scope=None)

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Feb 13, 2015
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 66b47b5 on dhermes:fix-638 into c6718f3 on GoogleCloudPlatform:master.

@@ -72,8 +73,34 @@ def get_credentials():
return client.GoogleCredentials.get_application_default()


def get_for_service_account_json(private_key_path, scope=None):

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@jgeewax
Copy link
Contributor

jgeewax commented Feb 14, 2015

This LGTM.

That said - I think it'd be useful to add an example which would ideally go in a separate "auth" section in the docs. Do we have an open issue for that or should I create one?

@jgeewax jgeewax added the auth label Feb 14, 2015
@dhermes
Copy link
Contributor Author

dhermes commented Feb 14, 2015

#633 is the issue, I actually have a branch I've been working on for awhile, I just keep getting sidetracked on it.

@dhermes
Copy link
Contributor Author

dhermes commented Feb 15, 2015

Renamed to json_credentials_path. @tseaver can you give a quick look before I merge?

"""Gets the credentials for a service account with JSON key.

:type json_credentials_path: string
:param json_credentials_path: The path to a private key file (this file was

This comment was marked as spam.

@tseaver
Copy link
Contributor

tseaver commented Feb 15, 2015

LGTM after pep8 passes.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling a80f1dd on dhermes:fix-638 into f64fc55 on GoogleCloudPlatform:master.

dhermes added a commit that referenced this pull request Feb 15, 2015
Adding get_for_service_account_json function in credentials.
@dhermes dhermes merged commit 61c6814 into googleapis:master Feb 15, 2015
@dhermes dhermes deleted the fix-638 branch February 15, 2015 19:13
vchudnov-g pushed a commit that referenced this pull request Sep 20, 2023
* feat: added dialogflow_assist_answer
feat: added session_ttl
feat: added human_agent_side_config
feat: added suggestion_input
feat: added suggest_dialogflow_assists_response
feat: added suggest_entity_extraction_response

PiperOrigin-RevId: 542021587

Source-Link: googleapis/googleapis@f40416d

Source-Link: googleapis/googleapis-gen@04ca491
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDRjYTQ5MWRlYzhmMzUxNzNlZTU5OWQ3ZWQwNzkzNmI0MDg2ZTk2ZCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* feat: added dialogflow_assist_answer
feat: added session_ttl
feat: added human_agent_side_config
feat: added suggestion_input
feat: added suggest_dialogflow_assists_response
feat: added suggest_entity_extraction_response

PiperOrigin-RevId: 542024928

Source-Link: googleapis/googleapis@06f7999

Source-Link: googleapis/googleapis-gen@0f124f3
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMGYxMjRmM2MzN2I1YTYwNDk5MDZhOTUxNGNkOTk0ZGFmMDczZGMwMSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: core auth cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow users to specify p12/json credentials file
5 participants