botocore.exceptions.UnauthorizedSSOTokenError: The SSO session associated with this profile has expired or is otherwise invalid. To refresh this SSO session run aws sso login with the corresponding profile.
import lakeapi
import datetime
def save_currency_rates_crypto_lake(symbols=["BTC-USDT"]):
lakeapi.use_sample_data(anonymous_access=True)
df = lakeapi.load_data(
table="book",
start=datetime.datetime(2022, 10, 1),
end=datetime.datetime(2022, 10, 2),
symbols=symbols,
exchanges=["BINANCE"],
)
print(df)
if __name__ == '__main__':
save_currency_rates_crypto_lake()
$ python3 dags/utils/crypto_lake.py
Traceback (most recent call last):
File "/home/user/.local/lib/python3.8/site-packages/botocore/credentials.py", line 2137, in _get_credentials
response = client.get_role_credentials(**kwargs)
File "/home/user/.local/lib/python3.8/site-packages/botocore/client.py", line 535, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/home/user/.local/lib/python3.8/site-packages/botocache/botocache.py", line 54, in _make_api_call
return super()._make_api_call(operation_name, api_params)
File "/home/user/.local/lib/python3.8/site-packages/botocore/client.py", line 983, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.UnauthorizedException: An error occurred (UnauthorizedException) when calling the GetRoleCredentials operation: Session token not found or invalid
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "dags/utils/crypto_lake.py", line 18, in <module>
save_currency_rates_crypto_lake()
File "dags/utils/crypto_lake.py", line 7, in save_currency_rates_crypto_lake
df = lakeapi.load_data(
File "/home/user/.local/lib/python3.8/site-packages/lakeapi/main.py", line 161, in load_data
df = lakeapi._read_parquet.read_parquet(
File "/home/user/.local/lib/python3.8/site-packages/lakeapi/_read_parquet.py", line 611, in read_parquet
dfs=_read_dfs_from_multiple_paths(
File "/home/user/.local/lib/python3.8/site-packages/lakeapi/_read.py", line 145, in _read_dfs_from_multiple_paths
kwargs["boto3_session"] = boto3_to_primitives(kwargs["boto3_session"])
File "/home/user/.local/lib/python3.8/site-packages/lakeapi/_utils.py", line 44, in boto3_to_primitives
"aws_access_key_id": getattr(credentials, "access_key", None),
File "/home/user/.local/lib/python3.8/site-packages/botocore/credentials.py", line 406, in access_key
self._refresh()
File "/home/user/.local/lib/python3.8/site-packages/botocore/credentials.py", line 499, in _refresh
self._protected_refresh(is_mandatory=is_mandatory_refresh)
File "/home/user/.local/lib/python3.8/site-packages/botocore/credentials.py", line 515, in _protected_refresh
metadata = self._refresh_using()
File "/home/user/.local/lib/python3.8/site-packages/botocore/credentials.py", line 662, in fetch_credentials
return self._get_cached_credentials()
File "/home/user/.local/lib/python3.8/site-packages/botocore/credentials.py", line 672, in _get_cached_credentials
response = self._get_credentials()
File "/home/user/.local/lib/python3.8/site-packages/botocore/credentials.py", line 2139, in _get_credentials
raise UnauthorizedSSOTokenError()
botocore.exceptions.UnauthorizedSSOTokenError: The SSO session associated with this profile has expired or is otherwise invalid. To refresh this SSO session run aws sso login with the corresponding profile.