René's URL Explorer Experiment


Title: Create client from service account stored in string · Issue #8 · googleapis/python-cloud-core · GitHub

Open Graph Title: Create client from service account stored in string · Issue #8 · googleapis/python-cloud-core

X Title: Create client from service account stored in string · Issue #8 · googleapis/python-cloud-core

Description: Hi, This was raised in python-storage: googleapis/python-storage#93 python-cloud-core library has support for from_service_account_json, which accepts a file path to a service account. Feature request is to add support to accept a json s...

Open Graph Description: Hi, This was raised in python-storage: googleapis/python-storage#93 python-cloud-core library has support for from_service_account_json, which accepts a file path to a service account. Feature requ...

X Description: Hi, This was raised in python-storage: googleapis/python-storage#93 python-cloud-core library has support for from_service_account_json, which accepts a file path to a service account. Feature requ...

Opengraph URL: https://github.com/googleapis/python-cloud-core/issues/8

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Create client from service account stored in string","articleBody":"Hi,\r\n\r\nThis was raised in python-storage: https://github.com/googleapis/python-storage/issues/93\r\n\r\npython-cloud-core library has support for [from_service_account_json](https://github.com/googleapis/python-cloud-core/blob/master/google/cloud/client.py#L50-L84), which accepts a file path to a service account. \r\n\r\nFeature request is to add support to accept a json string of the service account. User stores the service account file contents in an environment variable instead of in a file.\r\n\r\n**Open question**: I'm not sure if this is a path that should be supported so I'm leaving that as an open question in this issue. If this feature is not supported then the workaround is to construct a credentials object and explicitly set a project id:\r\n\r\n```python\r\n# Storage example but is a general issue AFAIU\r\n\r\nimport os\r\nimport json\r\n\r\nfrom google.cloud import storage\r\nfrom google.oauth2 import service_account\r\n\r\ncredentials_json_string = \"{...service account....}\"\r\n\r\ncredentials_json = json.loads(credentials_json_string)\r\ncredentials = service_account.Credentials.from_service_account_info(credentials_json)\r\n\r\n# Credentials has project_id already so project should be optional but it's not.\r\nclient = storage.Client(project=credentials['project_id'], credentials=credentials)\r\n\r\nprint(list(client.list_buckets()))\r\n```\r\n\r\n## Proposal:\r\n\r\n```python\r\n    @classmethod\r\n    def from_service_account_json_string(cls, json_credentials, *args, **kwargs):\r\n        \"\"\"Factory to create credentials with provided json_credentials.\r\n        :type json_credentials: str\r\n        :param json_credentials: The contents of a private key file. This string must contain\r\n                                      a JSON object with a private key and\r\n                                      other credentials information (downloaded\r\n                                      from the Google APIs console).\r\n        :type args: tuple\r\n        :param args: Remaining positional arguments to pass to constructor.\r\n        :param kwargs: Remaining keyword arguments to pass to constructor.\r\n        :rtype: :class:`_ClientFactoryMixin`\r\n        :returns: The client created with the provided JSON credentials.\r\n        :raises TypeError: if there is a conflict with the kwargs\r\n                 and the credentials created by the factory.\r\n        \"\"\"\r\n        if \"credentials\" in kwargs:\r\n            raise TypeError(\"credentials must not be in keyword arguments\")\r\n        credentials_info = json.load(json_credentials)\r\n        credentials = service_account.Credentials.from_service_account_info(\r\n            credentials_info\r\n        )\r\n        if cls._SET_PROJECT:\r\n            if \"project\" not in kwargs:\r\n                kwargs[\"project\"] = credentials_info.get(\"project_id\")\r\n\r\n        kwargs[\"credentials\"] = credentials\r\n        return cls(*args, **kwargs)\r\n```","author":{"url":"https://github.com/frankyn","@type":"Person","name":"frankyn"},"datePublished":"2020-04-17T23:39:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/8/python-cloud-core/issues/8"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:cc89a309-6d4e-13bf-b7ad-6ff345a8ca38
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB2EC:1960:158FD3B:1F0BAC8:6A4F772F
html-safe-nonce5a8cf6e6ed55dc19b0ffa10a94cea78205bceb37844afb22cba18c0fe9c87af5
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkVDOjE5NjA6MTU4RkQzQjoxRjBCQUM4OjZBNEY3NzJGIiwidmlzaXRvcl9pZCI6IjQ1MzgxNjQwMjI3MTM3NDMxNTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacd04558a1e02f12ffc54d6c0c61a1f8a845305556213db7b764975a5bdd434ce5
hovercard-subject-tagissue:602292681
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/python-cloud-core/8/issue_layout
twitter:imagehttps://opengraph.githubassets.com/5b420e08874128f553db801006b1df94d54901008361e394f365aa173e7fbe37/googleapis/python-cloud-core/issues/8
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/5b420e08874128f553db801006b1df94d54901008361e394f365aa173e7fbe37/googleapis/python-cloud-core/issues/8
og:image:altHi, This was raised in python-storage: googleapis/python-storage#93 python-cloud-core library has support for from_service_account_json, which accepts a file path to a service account. Feature requ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamefrankyn
hostnamegithub.com
expected-hostnamegithub.com
Noneb92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9
turbo-cache-controlno-preview
go-importgithub.com/googleapis/python-cloud-core git https://github.com/googleapis/python-cloud-core.git
octolytics-dimension-user_id16785467
octolytics-dimension-user_logingoogleapis
octolytics-dimension-repository_id226992462
octolytics-dimension-repository_nwogoogleapis/python-cloud-core
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id226992462
octolytics-dimension-repository_network_root_nwogoogleapis/python-cloud-core
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4b249b445842943ed31549e027f57a8ade9881ed
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/googleapis/python-cloud-core/issues/8#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-cloud-core%2Fissues%2F8
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgoogleapis%2Fpython-cloud-core%2Fissues%2F8
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=googleapis%2Fpython-cloud-core
Reloadhttps://github.com/googleapis/python-cloud-core/issues/8
Reloadhttps://github.com/googleapis/python-cloud-core/issues/8
Reloadhttps://github.com/googleapis/python-cloud-core/issues/8
Please reload this pagehttps://github.com/googleapis/python-cloud-core/issues/8
googleapis https://github.com/googleapis
python-cloud-corehttps://github.com/googleapis/python-cloud-core
Notifications https://github.com/login?return_to=%2Fgoogleapis%2Fpython-cloud-core
Fork 19 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-cloud-core
Star 34 https://github.com/login?return_to=%2Fgoogleapis%2Fpython-cloud-core
Code https://github.com/googleapis/python-cloud-core
Issues 0 https://github.com/googleapis/python-cloud-core/issues
Pull requests 0 https://github.com/googleapis/python-cloud-core/pulls
Actions https://github.com/googleapis/python-cloud-core/actions
Projects https://github.com/googleapis/python-cloud-core/projects
Security and quality 0 https://github.com/googleapis/python-cloud-core/security
Insights https://github.com/googleapis/python-cloud-core/pulse
Code https://github.com/googleapis/python-cloud-core
Issues https://github.com/googleapis/python-cloud-core/issues
Pull requests https://github.com/googleapis/python-cloud-core/pulls
Actions https://github.com/googleapis/python-cloud-core/actions
Projects https://github.com/googleapis/python-cloud-core/projects
Security and quality https://github.com/googleapis/python-cloud-core/security
Insights https://github.com/googleapis/python-cloud-core/pulse
#54https://github.com/googleapis/python-cloud-core/pull/54
Create client from service account stored in stringhttps://github.com/googleapis/python-cloud-core/issues/8#top
#54https://github.com/googleapis/python-cloud-core/pull/54
https://github.com/tseaver
type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.https://github.com/googleapis/python-cloud-core/issues?q=state%3Aopen%20label%3A%22type%3A%20feature%20request%22
https://github.com/frankyn
frankynhttps://github.com/frankyn
on Apr 17, 2020https://github.com/googleapis/python-cloud-core/issues/8#issue-602292681
googleapis/python-storage#93https://github.com/googleapis/python-storage/issues/93
from_service_account_jsonhttps://github.com/googleapis/python-cloud-core/blob/master/google/cloud/client.py#L50-L84
tseaverhttps://github.com/tseaver
type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.https://github.com/googleapis/python-cloud-core/issues?q=state%3Aopen%20label%3A%22type%3A%20feature%20request%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.