Skip to content

fix: Kraken email/api_key auth silent failure when both auth mixins are present#3737

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-kraken-eon-error
Open

fix: Kraken email/api_key auth silent failure when both auth mixins are present#3737
Copilot wants to merge 2 commits intomainfrom
copilot/fix-kraken-eon-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

When both oauth_mixin.py and kraken_auth_mixin.py are present (standard release package), _AUTH_BASE = OAuthMixin is always selected. Since KrakenAPI only inherits OAuthMixin, hasattr(self, "_init_kraken_auth") is False, so initialize() falls through to OAuthMixin._init_oauth() for auth_method="email". That sets access_token = None; OAuthMixin.check_and_refresh_oauth_token() then returns True for non-OAuth methods without obtaining a token — producing "Warn: Kraken: No access token for find-tariffs" on every GraphQL call.

Changes

  • kraken.py
    • Import KrakenAuthMixin at module level into _KrakenAuthMixin independently of _AUTH_BASE selection
    • Replace hasattr(self, "_init_kraken_auth") with _KrakenAuthMixin is not None (module-level check, not class-hierarchy check)
    • When auth_method in ("email", "api_key") and _KrakenAuthMixin is available, call _KrakenAuthMixin._init_kraken_auth(self, ...) directly and bind its token methods (check_and_refresh_oauth_token, handle_oauth_401, _kraken_token_request) to the instance, overriding OAuthMixin at the instance level
use_local_auth = auth_method in ("email", "api_key") and _KrakenAuthMixin is not None
if use_local_auth:
    _KrakenAuthMixin._init_kraken_auth(self, auth_method, key=key, email=email, ******
    self.check_and_refresh_oauth_token = _types.MethodType(_KrakenAuthMixin.check_and_refresh_oauth_token, self)
    self.handle_oauth_401 = _types.MethodType(_KrakenAuthMixin.handle_oauth_401, self)
    self._kraken_token_request = _types.MethodType(_KrakenAuthMixin._kraken_token_request, self)
  • tests/test_kraken.py
    • Added regression tests for email and api_key auth verifying access_token is actually obtained (not just True returned)
    • Added regression test confirming OAuth/SaaS mode is unaffected

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • gitlab.com
    • Triggering command: /usr/lib/git-core/git-remote-https /usr/lib/git-core/git-remote-https origin REDACTED (dns block)
  • https://api.github.com/repos/springfall2008/batpred/contents/apps/predbat
    • Triggering command: /home/REDACTED/work/batpred/batpred/coverage/venv/bin/python3 python3 ../apps/predbat/unit_test.py --test kraken --test kraken_auth (http block)

If you need me to access, download, or install something from one of these locations, you can either:

…ixins are present

Agent-Logs-Url: https://github.com/springfall2008/batpred/sessions/2084272c-dbbe-462e-8b42-9db2d65357ad

Co-authored-by: springfall2008 <48591903+springfall2008@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix kraken EON error for tariff retrieval fix: Kraken email/api_key auth silent failure when both auth mixins are present Apr 4, 2026
Copilot AI requested a review from springfall2008 April 4, 2026 15:27
@springfall2008 springfall2008 requested a review from mgazza April 4, 2026 19:02
@springfall2008 springfall2008 marked this pull request as ready for review April 5, 2026 13:54
Copilot AI review requested due to automatic review settings April 5, 2026 13:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a silent authentication failure in the Kraken integration when both oauth_mixin.py and kraken_auth_mixin.py ship together, ensuring auth_method="email" / "api_key" obtains a JWT instead of repeatedly proceeding with access_token=None.

Changes:

  • apps/predbat/kraken.py: Import KrakenAuthMixin independently of _AUTH_BASE selection and use a module-level availability check for local auth.
  • apps/predbat/kraken.py: For email/api_key auth, initialize via KrakenAuthMixin and bind its token-related methods onto the instance to override OAuthMixin behavior.
  • apps/predbat/tests/test_kraken.py: Add regression tests confirming email/api_key actually obtain and set access_token, and that OAuth mode remains unaffected.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
apps/predbat/kraken.py Ensures local Kraken auth works even when OAuthMixin is the selected base mixin by binding KrakenAuthMixin token methods per-instance.
apps/predbat/tests/test_kraken.py Adds regression coverage to prevent reintroducing the “True-but-no-token” behavior for local auth while preserving OAuth behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kraken EON error "Warn: Kraken: No access token for find-tariffs"

3 participants