Reputation: 1085
I am trying to authenticate a Google Admin SDK using ServiceAccountCredentials.from_json()
. I am using the Google Cloud Platform to run a Cloud Function. The Cloud Function gets a file from Cloud Storage, decrypts it, then uses that file to authenticate the service. According to this I can authenticate using from_json_keyfile_name
. I wont have a direct path though so I attempted to authenticate with the contents of the file from Google Console -> API -> Download credentials
. That json has the following keys:
However, ServiceAccountCredentials.from_json()
looks for _private_key_pkcs12
. which is not in the downloaded json.
Upvotes: 0
Views: 291
Reputation: 1085
oauth2client is deprecated. Use google.oauth2.service_account.
Example
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_info(sa_json)
return build(service_name, service_version, credentials=credentials)
Upvotes: 1