From 0b400f97be45808ade211ca8291b2e1d9476bde1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=95=B0=E7=BB=84=E8=B6=8A=E7=95=8C?= Date: Fri, 22 Oct 2021 03:55:34 +0800 Subject: [PATCH] docs: update thread_safety.md (#1568) An authorized http is required to build service, otherwise it will fail to read meta data. --- docs/thread_safety.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/thread_safety.md b/docs/thread_safety.md index d29ba71bffe..514972951a1 100644 --- a/docs/thread_safety.md +++ b/docs/thread_safety.md @@ -19,7 +19,8 @@ from googleapiclient import discovery def build_request(http, *args, **kwargs): new_http = google_auth_httplib2.AuthorizedHttp(credentials, http=httplib2.Http()) return googleapiclient.http.HttpRequest(new_http, *args, **kwargs) -service = discovery.build('api_name', 'api_version', requestBuilder=build_request) +authorized_http = google_auth_httplib2.AuthorizedHttp(credentials, http=httplib2.Http()) +service = discovery.build('api_name', 'api_version', requestBuilder=build_request, http=authorized_http) # Pass in a new Http() manually for every request service = discovery.build('api_name', 'api_version')