File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,6 +91,18 @@ session = Session.Builder() \
9191 .create()
9292```
9393
94+ ### Use Stored Credentials for Login
95+
96+ ``` python
97+ from librespot.core import Session
98+
99+ # Supports both Python and Rust librespot credential formats
100+
101+ session = Session.Builder() \
102+ .stored_file(" /path/to/credentials.json" ) \
103+ .create()
104+ ```
105+
94106### Get Spotify's OAuth token
95107
96108``` python
Original file line number Diff line number Diff line change @@ -1618,14 +1618,23 @@ def stored_file(self,
16181618 pass
16191619 else :
16201620 try :
1621+ # Try Python librespot format first
16211622 self .login_credentials = Authentication .LoginCredentials (
16221623 typ = Authentication .AuthenticationType .Value (
16231624 obj ["type" ]),
16241625 username = obj ["username" ],
16251626 auth_data = base64 .b64decode (obj ["credentials" ]),
16261627 )
16271628 except KeyError :
1628- pass
1629+ # Try Rust librespot format (auth_type as int, auth_data instead of credentials)
1630+ try :
1631+ self .login_credentials = Authentication .LoginCredentials (
1632+ typ = obj ["auth_type" ],
1633+ username = obj ["username" ],
1634+ auth_data = base64 .b64decode (obj ["auth_data" ]),
1635+ )
1636+ except KeyError :
1637+ pass
16291638 return self
16301639
16311640 def oauth (self , oauth_url_callback ) -> Session .Builder :
You can’t perform that action at this time.
0 commit comments