You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-3Lines changed: 49 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,7 +90,7 @@ with vertica_python.connect(**conn_info) as connection:
90
90
| ------------- | ------------- |
91
91
| host | The server host of the connection. This can be a host name or an IP address. <br>**_Default_**: "localhost" |
92
92
| port | The port of the connection. <br>**_Default_**: 5433 |
93
-
| user | The database user name to use to connect to the database. <br>**_Default_**:OS login user name |
93
+
| user | The database user name to use to connect to the database. <br>**_Default_**:<br> (for non-OAuth connections) OS login user name <br> (for OAuth connections) ""|
94
94
| password | The password to use to log into the database. <br>**_Default_**: "" |
95
95
| database | The database name. <br>**_Default_**: "" |
96
96
| autocommit | See [Autocommit](#autocommit). <br>**_Default_**: False |
@@ -103,7 +103,9 @@ with vertica_python.connect(**conn_info) as connection:
103
103
| kerberos_service_name | See [Kerberos Authentication](#kerberos-authentication). <br>**_Default_**: "vertica" |
104
104
| log_level | See [Logging](#logging). |
105
105
| log_path | See [Logging](#logging). |
106
-
| oauth_access_token | To authenticate via OAuth, provide an OAuth Access Token that authorizes a user to the database. <br>**_Default_**: "" |
106
+
| oauth_access_token | See [OAuth Authentication](#oauth-authentication). <br>**_Default_**: "" |
107
+
| oauth_refresh_token | See [OAuth Authentication](#oauth-authentication). <br>**_Default_**: "" |
108
+
| oauth_config | See [OAuth Authentication](#oauth-authentication). <br>**_Default_**: {} |
107
109
| request_complex_types | See [SQL Data conversion to Python objects](#sql-data-conversion-to-python-objects). <br>**_Default_**: True |
108
110
| session_label | Sets a label for the connection on the server. This value appears in the client_label column of the _v_monitor.sessions_ system table. <br>**_Default_**: an auto-generated label with format of `vertica-python-{version}-{random_uuid}`|
109
111
| ssl | See [TLS/SSL](#tlsssl). <br>**_Default_**: False (disabled) |
@@ -141,7 +143,7 @@ with vertica_python.connect(dsn=connection_str, **additional_info) as conn:
141
143
```
142
144
143
145
#### TLS/SSL
144
-
You can pass `True` to `ssl` to enable TLS/SSL connection (Internally [ssl.wrap_socket(sock)](https://docs.python.org/3/library/ssl.html#ssl.wrap_socket) is called).
146
+
You can pass `True` to `ssl` to enable TLS/SSL connection (equivalent to TLSMode=require).
145
147
146
148
```python
147
149
import vertica_python
@@ -258,6 +260,50 @@ with vertica_python.connect(**conn_info) as conn:
258
260
# do things
259
261
```
260
262
263
+
#### OAuth Authentication
264
+
To authenticate via OAuth, one way is to provide an `oauth_access_token` that authorizes a user to the database.
265
+
```python
266
+
import vertica_python
267
+
268
+
conn_info = {'host': '127.0.0.1',
269
+
'port': 5433,
270
+
'database': 'a_database',
271
+
# valid OAuth access token
272
+
'oauth_access_token': 'xxxxxx'}
273
+
274
+
with vertica_python.connect(**conn_info) as conn:
275
+
# do things
276
+
```
277
+
In cases where `oauth_access_token` is not set or introspection fails (e.g. when the access token expires), the client can do a token refresh when both `oauth_refresh_token` and `oauth_config` are set. The client will retrieve a new access token from the identity provider and use it to connect with the database.
The following table lists the `oauth_config` parameters used to configure OAuth token refresh:
297
+
298
+
| Parameter | Description |
299
+
| ------------- | ------------- |
300
+
| client_id | The client ID of the client application registered in the identity provider. |
301
+
| client_secret | The client secret of the client application registered in the identity provider.|
302
+
| token_url | The endpoint to which token refresh requests are sent. The format for this depends on your provider. For examples, see the [Keycloak](https://www.keycloak.org/docs/latest/securing_apps/#token-endpoint) and [Okta](https://developer.okta.com/docs/reference/api/oidc/#token) documentation.|
303
+
| discovery_url | Also known as the [OpenID Provider Configuration Document](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfigurationRequest), this endpoint contains a list of all other endpoints supported by the identity provider. If set, *token_url* do not need to be specified.<br>If you set both *discovery_url* and *token_url*, then *token_url* takes precedence.|
304
+
| scope | The requested OAuth scopes, delimited with spaces. These scopes define the extent of access to the resource server (in this case, Vertica) granted to the client by the access token. For details, see the [OAuth documentation](https://www.oauth.com/oauth2-servers/scope/defining-scopes/). |
305
+
306
+
261
307
#### Logging
262
308
Logging is disabled by default if neither ```log_level``` or ```log_path``` are set. Passing value to at least one of those options to enable logging.
0 commit comments