Authorization
_Clients
¶
Bases: object
Base client object for authorization to all Google APIs.
This object contains methods to authorize local files, Credentials objects, and more.
Source code in pygsuite/auth/authorization.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
__init__()
¶
auth_default(project=None)
¶
Gets the default credentials for the current environment. More information in Google's default auth documentation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project |
Optional[str]
|
The project ID. |
None
|
Sets the client auth to the default credentials fetched from Google.
Source code in pygsuite/auth/authorization.py
authorize(auth, project=None)
¶
Sets the credentials for the current environment to a given Credentials object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth |
Credentials
|
A valid |
required |
project |
Optional[str]
|
The project ID, not currently used. |
None
|
Source code in pygsuite/auth/authorization.py
authorize_string(auth_string)
¶
Sets the credentials for the current environment based on a JSON-like credentials string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
auth_string |
str
|
A JSON-like string containing credentials information to be authenticated. |
required |
Source code in pygsuite/auth/authorization.py
create_client_file_from_string()
¶
Creates a OAuth 2.0 Authorization Flow object from a credential string if provided.
Returns a constructed Flow object with credential information from credential string.
Source code in pygsuite/auth/authorization.py
docs_client()
¶
drive_client()
¶
drive_client_v2()
¶
drive_client_v3()
¶
forms_client()
¶
local_file_auth(filepath=None)
¶
Sets the credentials for the current environment based on a local file with credentials.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath |
Optional[str]
|
Filepath to the credentials file, will default to token.json in working directory. |
None
|
Source code in pygsuite/auth/authorization.py
sheets_client()
¶
slides_client()
¶
validate()
¶
Method to verify authorization has been obtained.
Raises a ValueError if no Credentials object exists in self.auth.
Source code in pygsuite/auth/authorization.py
get_oauth_credential(credential_string)
¶
Convert a JSON-like string into a Google OAuth Credentials object,
and refresh the credentials if they are expired and contain a refresh token.
Raises a ValueError if invalid credentials cannot be refreshed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credential_string |
str
|
A JSON-like string containing Google authentication information. |
required |
Returns a valid Credentials object.
Source code in pygsuite/auth/authorization.py
json_str_to_oauth(token_str)
¶
Convert a JSON-like string into a Google OAuth Credentials object or a service account object, depending on what was provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
token_str |
str
|
A JSON-like string containing Google authentication information. |
required |
Returns a Credentials object.