addianto / botofculture-discord

Ah. I see you are looking for a bot of culture.
MIT License
2 stars 1 forks source link

Problem with Pixiv authentication #6

Open addianto opened 3 years ago

addianto commented 3 years ago

As mentioned at https://github.com/upbit/pixivpy/issues/158, username/password-based login does not work since the beginning of this year (2021). The authentication API now enforces OAuth2 and token-based authentication. Since I am not really versed with OAuth2 or modern Web authentication, a helping hand would be nice. :))

One example of log produced from current instance of the bot:

Mar 13 22:26:23 cocoa python[25371]:     raise AuthCredentialsError(code, r)
Mar 13 22:26:23 cocoa python[25371]: pixivpy_async.error.AuthCredentialsError: Run auth() failed! Check username and password.
Mar 13 22:26:23 cocoa python[25371]: HTTP 400: {'has_error': True, 'errors': {'system': {'message': 'Invalid grant_type parameter or parameter missing', 'code': 1508}}, 'error': 'invalid_grant'}
thrzl commented 3 years ago

I'm just spitballing, I didn't know pixiv existed until I saw this bot. I saw that on pixivpy's README, there is this message: image

Is this what you're looking for?

addianto commented 3 years ago

I'm just spitballing, I didn't know pixiv existed until I saw this bot. I saw that on pixivpy's README, there is this message: image

Is this what you're looking for?

Yes. That one.

I have tried the first workaround to obtain the refresh_token and I was able to get the refresh_token successfully. Afterward, I tried to replace the credentials used during authentication (see: botofculture/pixiv.py line 33 - 34 on master branch) with api.login(refresh_token=THE_REFRESH_TOKEN. But it still does not work. 💦

So.. I guess the issue is in the Pixiv API library. This project uses pixivpy-async instead of pixivpy that suggested the workarounds you mentioned before.

thrzl commented 3 years ago

Ahh, I see. The best straightforward solution I can see at this point would be to use Aiohttp for raw requests to the API.