[GH-ISSUE #4] Importing cookies error #2

Closed
opened 2026-02-27 19:06:23 +03:00 by kerem · 2 comments
Owner

Originally created by @Ishannaik on GitHub (Sep 21, 2024).
Original GitHub issue: https://github.com/Aran404/SpotAPI/issues/4


Traceback (most recent call last):
  File "sp.py", line 22, in <module>
    saver.save([cookies])
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\spotapi\utils\saver.py", line 68, in save
    current = [
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\spotapi\utils\saver.py", line 71, in <listcomp>
    if not any(
  File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\spotapi\utils\saver.py", line 72, in <genexpr>
    item["identifier"] == d["identifier"] for d in data
TypeError: string indices must be integers

Getting error here


from spotapi import Login, Config, NoopLogger, JSONSaver

# Correctly structured cookies
cookies = {
    "identifier": "",  
    "cookies": {
        "sp_dc": "",  
        "sp_key": "",  
    },
}

cfg = Config(
    solver=None, 
    logger=NoopLogger(),  
)

saver = JSONSaver()

saver.save([cookies])

instance = Login.from_saver(saver, cfg)

user_info = instance.user.me()
print(f"Logged in as: {user_info['display_name']}")

Originally created by @Ishannaik on GitHub (Sep 21, 2024). Original GitHub issue: https://github.com/Aran404/SpotAPI/issues/4 ``` Traceback (most recent call last): File "sp.py", line 22, in <module> saver.save([cookies]) File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\spotapi\utils\saver.py", line 68, in save current = [ File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\spotapi\utils\saver.py", line 71, in <listcomp> if not any( File "C:\Users\xxx\AppData\Local\Programs\Python\Python310\lib\site-packages\spotapi\utils\saver.py", line 72, in <genexpr> item["identifier"] == d["identifier"] for d in data TypeError: string indices must be integers ``` Getting error here ``` from spotapi import Login, Config, NoopLogger, JSONSaver # Correctly structured cookies cookies = { "identifier": "", "cookies": { "sp_dc": "", "sp_key": "", }, } cfg = Config( solver=None, logger=NoopLogger(), ) saver = JSONSaver() saver.save([cookies]) instance = Login.from_saver(saver, cfg) user_info = instance.user.me() print(f"Logged in as: {user_info['display_name']}") ```
kerem closed this issue 2026-02-27 19:06:23 +03:00
Author
Owner

@Aran404 commented on GitHub (Sep 21, 2024):

Please provide a working example so I can recreate the error. There is a lot of things wrong in this code. Use an IDE.

<!-- gh-comment-id:2365233657 --> @Aran404 commented on GitHub (Sep 21, 2024): Please provide a working example so I can recreate the error. There is a lot of things wrong in this code. Use an IDE.
Author
Owner

@Ishannaik commented on GitHub (Sep 22, 2024):

Can you add an example code for a cookie login in the readme

<!-- gh-comment-id:2366785223 --> @Ishannaik commented on GitHub (Sep 22, 2024): Can you add an example code for a cookie login in the readme
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SpotAPI#2
No description provided.