Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REST API - invalid username/password error even with valid credentials #55

Open
Behinder opened this issue Sep 3, 2022 · 12 comments
Open

Comments

@Behinder
Copy link

Behinder commented Sep 3, 2022

As in topic. Tested in PAW.

@hucario
Copy link

hucario commented Sep 4, 2022

Have you read through #45 ?

@Behinder
Copy link
Author

Behinder commented Sep 4, 2022 via email

@hucario
Copy link

hucario commented Sep 4, 2022

OK, so the workaround we figured out is thus:

  • The user auth token (UAT) you get from the JSON api works with the REST api as well
  • log in with the JSON api
  • use the UAT provided by that for the REST api

holdups / possible problem points:

  • the JSON api requires you to have a User-Agent of libcurl. We haven't tested very many others, but we know that one works and browser User-Agents generally don't.
  • the JSON api uses an encryption (more than just using TLS, as this was made before TLS became widely used(!)) for security over insecure connections (i.e. straight HTTP). this is pain. the partner login step doesn't use this, but the user login step does

i'll post working example code Soon:tm:. it'll be Typescript, because that's what I use

@Behinder
Copy link
Author

Behinder commented Sep 4, 2022 via email

@hucario
Copy link

hucario commented Sep 4, 2022

Alright, here's an implementation ripped straight from hucario/Anesidora:typescript and further lobotomized for just the purpose of getting a UAT. I have tested this precisely 0 times, but it should show what you need to do.

https://gist.github.com/hucario/9ca6b9f6a16d7d9a26573c7ca740ff03

If it helps, here are the typings I use for the Pandora API:
https://gist.github.com/hucario/b222408a7d4ed7c2cc18c2878de18332

@Behinder
Copy link
Author

Behinder commented Sep 5, 2022 via email

@hacker1024
Copy link
Contributor

@Behinder
Maybe this is useful to you - I made a cross-platform CLI tool that logs in to Pandora and retrieves an authentication token. It works well programmatically through standard input and output channels.

https://github.com/EpimetheusMusicPlayer/pandora_authenticator

Dart is not the best language for such a tool (the resultant programs are relatively large and slow), but I'm leveraging my existing library so I didn't have much of a choice. It might be a good project to rewrite as I learn Rust - but I can't promise anything.

@Behinder
Copy link
Author

Behinder commented Sep 7, 2022

Thank you very much for the effort. I learned what you recently discovered that some programming language are not suitable to do certain task. Big appreciation that you were able to finish this CLI tool.

for reason unknown dart pub get gives me error I cannot connect to github, which is weirs as I was able to clone your repo.

@hacker1024
Copy link
Contributor

Ah, that's because I was using the no-longer-supported git:// protocol - try now. I also have binaries for every platform in the releases.

@Behinder
Copy link
Author

Behinder commented Sep 8, 2022

It really looks that API is impossible to use :(

Ok I was able to get token from your binary, however token received is invalid. After doing request I always get:

{
  "errorCode": 1001,
  "errorString": "INVALID_REQUEST",
  "message": "Auth Token is Expired - VIKLISw0a56rHjOglxdTCMUStTA0jpbWChFfyWDkRKa1wCjsywEztEgA=="
}

I am also including in request X-CsrfToken taken from HEAD request:

HTTP/1.1 200 OK
Date: Thu, 08 Sep 2022 13:17:24 GMT
Server: Apache
Content-Type: text/html;charset=utf-8
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Strict-Transport-Security: max-age=31536000
X-Frame-Options: SAMEORIGIN
Set-Cookie: v2regbstage=;Path=/;Domain=.pandora.com;Expires=Thu, 01-Jan-1970 00:00:00 GMT;Max-Age=0
Set-Cookie: csrftoken=259fbd3e7ae5a46a;Path=/;Domain=.pandora.com;Secure
Connection: close

so either authtoken is invalid just few seconds after generation, or expired cookie invalidates token.

@hucario
Copy link

hucario commented Sep 9, 2022

Alternatively, you could use the JSON API, which - while clumsier - still does work. That's what I use, and I have few problems

@Behinder
Copy link
Author

Behinder commented Oct 11, 2022 via email

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

No branches or pull requests

3 participants