Retrieve a valid auth token. If caching is enabled, we will first try to retrieve cached token from a file system. If cached token is expired or not available, we will try to authenticate using the provided credentials and retrieve a new auth token.
(self, client, username, password, cache_token)
| 231 | return path |
| 232 | |
| 233 | def _get_auth_token(self, client, username, password, cache_token): |
| 234 | """ |
| 235 | Retrieve a valid auth token. |
| 236 | |
| 237 | If caching is enabled, we will first try to retrieve cached token from a |
| 238 | file system. If cached token is expired or not available, we will try to |
| 239 | authenticate using the provided credentials and retrieve a new auth |
| 240 | token. |
| 241 | |
| 242 | :rtype: ``str`` |
| 243 | """ |
| 244 | if cache_token: |
| 245 | token = self._get_cached_auth_token( |
| 246 | client=client, username=username, password=password |
| 247 | ) |
| 248 | else: |
| 249 | token = None |
| 250 | if not token: |
| 251 | # Token is either expired or not available |
| 252 | token_obj = self._authenticate_and_retrieve_auth_token( |
| 253 | client=client, username=username, password=password |
| 254 | ) |
| 255 | |
| 256 | self._cache_auth_token(token_obj=token_obj) |
| 257 | token = token_obj.token |
| 258 | |
| 259 | return token |
| 260 | |
| 261 | def _get_cached_auth_token(self, client, username, password): |
| 262 | """ |
no test coverage detected