Skip to content

Add robust OAuth authentication system with PKCE#32

Open
brunobiking wants to merge 7 commits intodevicelocksmith:masterfrom
brunobiking:oauth-integration
Open

Add robust OAuth authentication system with PKCE#32
brunobiking wants to merge 7 commits intodevicelocksmith:masterfrom
brunobiking:oauth-integration

Conversation

@brunobiking
Copy link

🎯 Objectifs

  • Intégrer un système d'authentification OAuth 2.0 robuste avec PKCE
  • Permettre l'utilisation de credentials Tidal personnels
  • Améliorer la stabilité et la sécurité de l'authentification
  • Fournir une alternative aux API keys publiques instables

🐛 Problèmes résolus

  1. Erreur 1005 : Les API keys publiques sont régulièrement bloquées par Tidal
  2. Authentification instable : Dépendance aux clés publiques non maintenues
  3. Manque de contrôle : Impossible d'utiliser ses propres credentials

🔧 Changements

Nouveaux fichiers

  • tidal_dl/oauth_auth. py : Système OAuth complet avec PKCE et serveur callback
  • .env.example : Template de configuration pour credentials
  • README_OAUTH.md : Documentation complète

Fichiers modifiés

  • requirements.txt : Ajout de python-dotenv
  • .gitignore : Protection des fichiers sensibles (. env, tokens)

📋 Prérequis pour utilisation

  1. Créer une application sur https://developer.tidal.com/
  2. Configurer le redirect URI : http://localhost:8080/callback
  3. Créer un fichier .env avec vos credentials (voir . env.example)

🔑 Fonctionnalités

  • ✅ Authentification OAuth 2.0 avec PKCE (Proof Key for Code Exchange)
  • ✅ Serveur de callback local automatique
  • ✅ Gestion sécurisée des tokens (stockage local)
  • ✅ Refresh automatique des access tokens
  • ✅ Protection des credentials via .env (non versionné)

⚠️ Limitations connues

  • L'API publique Tidal ne permet pas le téléchargement haute qualité
  • Destiné à un usage personnel et éducatif uniquement
  • Nécessite la création d'une application Tidal Developer

🧪 Tests effectués

  • ✅ Génération correcte du code_verifier et code_challenge (PKCE)
  • ✅ Ouverture automatique du navigateur pour authentification
  • ✅ Serveur callback local fonctionnel sur port 8080
  • ✅ Échange code → access_token + refresh_token
  • ✅ Stockage sécurisé des tokens dans ~/. tidal-dl-oauth.token.json
  • ✅ Protection des fichiers sensibles via .gitignore

📚 Utilisation

from tidal_dl.oauth_auth import TidalOAuth

# Initialiser avec credentials depuis .env
oauth = TidalOAuth()

# Authentifier (ouvre navigateur)
if oauth.authenticate():
    token = oauth.get_access_token()
    print(f"Token: {token}")

- Add oauth_auth.py with robust OAuth 2.0 implementation
- Add .env.example template for user credentials
- Add README_OAUTH.md documentation
- Update . gitignore to protect sensitive files
- Add python-dotenv dependency to requirements.txt

This implementation provides:
- PKCE-based OAuth authentication
- Local callback server for authorization code
- Automatic token refresh
- Secure credential management via . env files

Note: Requires creating a Tidal Developer app at https://developer.tidal.com/
Copilot AI review requested due to automatic review settings November 29, 2025 05:11
Copy link

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

This PR introduces a robust OAuth 2.0 authentication system with PKCE (Proof Key for Code Exchange) for Tidal API access, providing an alternative to unstable public API keys. The implementation aims to resolve authentication issues (Error 1005) and give users control over their credentials.

Key Changes:

  • New OAuth authentication module with PKCE support and local callback server
  • Documentation for setting up custom Tidal developer credentials
  • Added python-dotenv dependency for secure credential management

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 25 comments.

File Description
TIDALDL-PY/tidal_dl/oauth_auth.py New OAuth 2.0 authentication module with PKCE and HTTP callback handler (incomplete/truncated)
TIDALDL-PY/requirements.txt Added python-dotenv 1.0.0 dependency for environment variable management
TIDALDL-PY/README_OAUTH.md Comprehensive setup and usage documentation (contains markdown formatting issues)

Critical Issues Found:

  • The oauth_auth.py file is truncated/incomplete at line 56-57, making it non-functional
  • Thread-safety concern with class-level variables for storing OAuth callback state
  • Extensive markdown formatting issues in README_OAUTH.md due to escaped backslashes throughout the document

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

brunobiking and others added 6 commits November 29, 2025 00:34
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@brunobiking
Copy link
Author

done

@brunobiking brunobiking reopened this Nov 29, 2025
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.

2 participants