Returns an http client that is authorized with the given credentials. Args: credentials (Union[ google.auth.credentials.Credentials, oauth2client.client.Credentials]): The credentials to use. Returns: Union[httplib2.Http, google_auth_httplib2.Authori
(credentials)
| 98 | |
| 99 | |
| 100 | def authorized_http(credentials): |
| 101 | """Returns an http client that is authorized with the given credentials. |
| 102 | |
| 103 | Args: |
| 104 | credentials (Union[ |
| 105 | google.auth.credentials.Credentials, |
| 106 | oauth2client.client.Credentials]): The credentials to use. |
| 107 | |
| 108 | Returns: |
| 109 | Union[httplib2.Http, google_auth_httplib2.AuthorizedHttp]: An |
| 110 | authorized http client. |
| 111 | """ |
| 112 | from googleapiclient.http import build_http |
| 113 | |
| 114 | if HAS_GOOGLE_AUTH and isinstance(credentials, google.auth.credentials.Credentials): |
| 115 | if google_auth_httplib2 is None: |
| 116 | raise ValueError( |
| 117 | "Credentials from google.auth specified, but " |
| 118 | "google-api-python-client is unable to use these credentials " |
| 119 | "unless google-auth-httplib2 is installed. Please install " |
| 120 | "google-auth-httplib2." |
| 121 | ) |
| 122 | return google_auth_httplib2.AuthorizedHttp(credentials, http=build_http()) |
| 123 | else: |
| 124 | return credentials.authorize(build_http()) |
| 125 | |
| 126 | |
| 127 | def refresh_credentials(credentials): |
nothing calls this directly
no test coverage detected
searching dependent graphs…