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

Cannot use the login function #26

Closed
john-erinjery opened this issue Apr 8, 2023 · 8 comments · Fixed by #32
Closed

Cannot use the login function #26

john-erinjery opened this issue Apr 8, 2023 · 8 comments · Fixed by #32
Assignees
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed

Comments

@john-erinjery
Copy link
Contributor

I wanted to fetch my reading list from my mangadex account, so I tried using the Api().login() method. However, no matter how many times I do it or how many times I confirm my username and password, I got this traceback :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Programing\python-web\env\Lib\site-packages\mangadex\api.py", line 539, in login
    self.__auth_handler(json_payload= {"username" : username, "password" : password})
  File "C:\Programing\python-web\env\Lib\site-packages\mangadex\api.py", line 14, in __auth_handler
    auth = URLRequest.request_url(url, "POST", params = json_payload, timeout=self.timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Programing\python-web\env\Lib\site-packages\mangadex\url_models.py", line 59, in request_url
    raise ApiError(resp)
          ^^^^^^^^^^^^^^
  File "C:\Programing\python-web\env\Lib\site-packages\mangadex\errors.py", line 15, in __init__
    self.details = self.resp.text["detail"]
                   ~~~~~~~~~~~~~~^^^^^^^^^^
TypeError: string indices must be integers, not 'str'

I tried using the official api using this code :

>>> import requests
>>> data = {'username' : ' ---', 'password' : '----'}
>>> url = "https://api.mangadex.org/auth/login"
>>> r = requests.post(url, json=data)
>>> r.json()
{'result': 'error', 'errors': [{'id': '70289a8c-eed8-5c0e-989b-4c73c13bf791', 'status': 401, 'title': 'unauthorized_http_exception', 'detail': 'User / Password does not match', 'context': None}]}

as you can see there's that error. so i figured it was a problem with the official api, am i correct?
and if It is a problem with the official api, is there any other way of getting my reading lists?

@EMACC99
Copy link
Owner

EMACC99 commented Apr 10, 2023

Hello, seems that the current method for login has been deprecated, and we need to migrate to the new OAuth2 login system. I will investigate further how to implement it. For getting the reading lists, unfortunately, there is no way to get a user's manga library without being on a public reading list.

@EMACC99 EMACC99 pinned this issue Apr 10, 2023
@EMACC99 EMACC99 added bug Something isn't working enhancement New feature or request help wanted Extra attention is needed labels Apr 10, 2023
@EMACC99 EMACC99 added this to the Migrate to OAuth2 for login milestone Apr 10, 2023
@EMACC99 EMACC99 self-assigned this Apr 10, 2023
@EMACC99
Copy link
Owner

EMACC99 commented Apr 10, 2023

Hello again, can you retry the login? As I was debugging I couldn't replicate the issue (the migration to OAuth will still happen) as the endpoint seems to be up still. Can you include which version of the library you are using?

@john-erinjery
Copy link
Contributor Author

Hello, thanks for looking into it!
I'm on version 2.5.2 of the wrapper.

@john-erinjery
Copy link
Contributor Author

john-erinjery commented Apr 11, 2023

I confirmed the error is still present, and i tried to login with another account only to get the same result.
Ahh for additional info, I did try asking in the mangadex forum on reddit and this is the info I got :

image

here's the link to the discussion

Do you think it might be because of regional differences?

@MrSoupman
Copy link

Hi, I found this on the MangaDex discord:
image
That might answer your question, and might be why it wasn't repeatable during debugging.

@john-erinjery
Copy link
Contributor Author

Oh so that was the reason huh. Thanks a lot for that! I figured out how to login with the bearer text but it was pretty inefficient, and using selenium is gonna make my program a lot slower and bulkier...guess I'll wait for OAuth to be implemented. It ain't implemented yet right? Where can I find out if it got implemented?

@EMACC99
Copy link
Owner

EMACC99 commented May 10, 2023

Sorry for the very late response, I've been attending some IRL matters and couldn't dedicate much time to the followup in this issue.

I came across a quite old announcement in the discord server that the oauth is still in the dev phase, however, I'm not sure if this contains up to date user data as from my understanding is just for testing the integration

image

(yes, I use discord in light mode, sorry if it burned your eyes)

As you saw in your investigation, there is not a way to register a third-party client right now so our only hope is that the .dev has everything we need for the new account authentications, but I'm not sure about the reliability of using it for every login or just using it for the accounts that are in a case similar to yours. If anyone have an idea on how to approach this, you're more than welcome to share it.

@lasersPew
Copy link
Contributor

They have added it to the production server. Note: See #32.

In the changes in that code and in the spec, it says that it needs to have client id and client secret after you created an app in the API clients in the settings though it will work for the accounts that created the apps themselves.

After some testing with this code:

username = #redacted
password = #redacted
clientId = #redacted
clientSecret = #redacted

resp = requests.post(url, data = {"grant_type": "password",  "username": username,  "password": password, "client_id" : clientId, "client_secret" : clientSecret})

resp = resp.json()

It spits out token type, scope, and client type (useful when public clients are implemented) and the access and refresh token among other things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants