Reference for hub_sdk/base/auth.py
Note
This file is available at https://github.com/ultralytics/hub-sdk/blob/main/hub_sdk/base/auth.py. If you spot a problem please help fix it by contributing a Pull Request 🛠️. Thank you 🙏!
hub_sdk.base.auth.Auth
Represents an authentication manager.
Attributes:
Name | Type | Description |
---|---|---|
api_key |
(str, None)
|
The API key used for authentication. |
id_token |
(str, None)
|
The authentication token. |
Source code in hub_sdk/base/auth.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 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 |
|
__init__()
authenticate()
Attempt to authenticate with the server using either id_token or API key.
Returns:
Type | Description |
---|---|
bool
|
True if authentication is successful, False otherwise. |
Raises:
Type | Description |
---|---|
ConnectionError
|
If request response fails, raise connection error exception. |
Source code in hub_sdk/base/auth.py
authorize(email, password)
Authorize the user by obtaining an idToken through a POST request with email and password.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
email |
str
|
User's email. |
required |
password |
str
|
User's password. |
required |
Returns:
Type | Description |
---|---|
bool
|
True if authorization is successful, False otherwise. |
Source code in hub_sdk/base/auth.py
get_auth_header()
Get the authentication header for making API requests.
Returns:
Type | Description |
---|---|
Optional[dict]
|
The authentication header if id_token or API key is set, None otherwise. |
Source code in hub_sdk/base/auth.py
get_state()
Get the authentication state.
Returns:
Type | Description |
---|---|
bool
|
True if either id_token or API key is set, False otherwise. |
set_api_key(key)
Set the API key for authentication.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The API key string. |
required |