coinbase / coinbase-advanced-py

The Advanced API Python SDK is a Python package that makes it easy to interact with the Coinbase Advanced API. The SDK handles authentication, HTTP connections, and provides helpful methods for interacting with the API.
https://docs.cloud.coinbase.com/advanced-trade-api
Apache License 2.0
91 stars 24 forks source link

Authentication error on second page when getting account transactions #59

Open eprbell opened 4 weeks ago

eprbell commented 4 weeks ago

Thanks for this project: it's very useful. I'm running into an issue when calling client.get(f"/v2/accounts/{account_id}/transactions").

My code is fairly simple:

    def __get_transactions(self, account_id: str) -> Dict[str, Any]:
        results: List[Dict[str, Any]] = []
        cursor: Optional[str] = None
        current_uri: str = f"/v2/accounts/{account_id}/transactions"
        while True:
            current_page = self.__client.get(current_uri)
            if _DATA in current_page:
                results.extend(current_page[_DATA])
            if _PAGINATION not in current_page or _NEXT_URI not in current_page[_PAGINATION] or not current_page[_PAGINATION][_NEXT_URI]:
                break
            current_uri = current_page[_PAGINATION][_NEXT_URI]
        return results

The first page (the one with URI `f"/v2/accounts/{account_id}/transactions") is retrieved correctly, but the second one (with the next URI) is not and I'm getting:

2024-07-01 19:51:06 - coinbase.RESTClient - ERROR - HTTP Error: 401 Client Error: Unauthorized Unauthorized

The fact that the first page is retrieved correctly suggests that authentication is correct, but I'm not sure why the following pages cause this problem. Any help would be appreciated!

github-actions[bot] commented 4 weeks ago

Thank you for reporting! If this is an SDK specific issue, we will look into it and get back to you soon. If this is an API related request, report it in our Advanced API Discord instead (use this invite link if it's your first time accessing the Discord).