From da8bb13c1349e771ffc2e125256030495c53d956 Mon Sep 17 00:00:00 2001 From: bojeil-google Date: Mon, 9 Aug 2021 21:23:25 -0700 Subject: [PATCH] fix: downscoping documentation bugs (#830) Fixes the following issues: - Change `google.oauth2.Credentials` to `google.oauth2.credentials.Credentials` - Replace deprecated `blob.download_as_string()` with `blob.download_as_bytes()` --- docs/user-guide.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/user-guide.rst b/docs/user-guide.rst index de284b881..ccece5751 100644 --- a/docs/user-guide.rst +++ b/docs/user-guide.rst @@ -507,7 +507,7 @@ Token Consumer :: # refresh handler to handle token expiration. Passing the original # downscoped token or the expiry here is optional, as the refresh_handler # will generate the downscoped token on demand. - credentials = google.oauth2.Credentials( + credentials = google.oauth2.credentials.Credentials( downscoped_token, expiry=expiry, scopes=['https://www.googleapis.com/auth/cloud-platform'], @@ -521,7 +521,7 @@ Token Consumer :: # in bucket "bucket-123". bucket = storage_client.bucket('bucket-123') blob = bucket.blob('customer-a-data.txt') - print(blob.download_as_string()) + print(blob.download_as_bytes().decode("utf-8")) Another reason to use downscoped credentials is to ensure tokens in flight