Nandaka / PixivUtil2

Download images from Pixiv and more!
http://nandaka.devnull.zone/
BSD 2-Clause "Simplified" License
2.38k stars 257 forks source link

"Invalid grant_type parameter or parameter missing" error when downloading from FANBOX #914

Closed akeboshiKOU closed 3 years ago

akeboshiKOU commented 3 years ago

Prerequisites

Description

Pulling from a specific FANBOX page (id=57188403) will result in error. Pulling specific posts from the affected page will error as well.

One thing to note, the FANBOX page does not have a corresponding Pixiv page, however I've successfully retrieved posts from other FANBOX pages that do not have any linked Pixiv before. Might be because the page is relatively new? (8-digits, 5--- ----)

Steps to Reproduce

Input: f2 Artist/Creator IDs = 57188403 End page =

[...]

Invalid grant_type parameter or parameter missing Error getting FANBOX artist by id: 57188403 ==> Failed to login using OAuth

Versions

pixivutil20210215-beta1 (with updated PHPSESSID values)

Nandaka commented 3 years ago

can you try to remove the 'refresh_token' from the config.ini?

dmo140230 commented 3 years ago

Same thing is happening to me. I tried removing the 'refresh_token' property from the config, but the issue persists

Nandaka commented 3 years ago

hmm, weird... It is working if I'm running from source using python script, but not if it from the compiled.

akeboshiKOU commented 3 years ago

Tried running v20210221-beta2 source with latest Python 3.9.2 (64-bit) but still encountered the same error. Tested again with clean config.ini (only Authentication and FFmpeg.exe changed), same issue.

Nandaka commented 3 years ago

yeah, somehow oAuth only works if you run from source code.

akeboshiKOU commented 3 years ago

But I'm running from source code :o Somehow double-clicking on PixivUtil2.py doesn't work for me (window closes immediately) so I'm running it from cmd using "python.exe c:\pixivutil\PixivUtil2.py" Am I doing something wrong? Should I try installing Python 32-bit instead?

Nandaka commented 3 years ago

See https://github.com/Nandaka/PixivUtil2/wiki/IDE-Enviroment-(Windows)

akeboshiKOU commented 3 years ago

Downgraded to Python 3.8.8 32-bit, same error when run on CMD or VS Code VS code

bluerthanever commented 3 years ago

i am using WIN10, 64-bit python, and i don't have such problems yet... but when i was testing #907, my situation was that, if i delete the saved refresh token, i would get the same error:

2021-02-10 22:02:27,772 - PixivUtil20210108-beta4 - DEBUG - 400: {"has_error":true,"errors":{"system":{"message":"Invalid grant_type parameter or parameter missing","code":1508}},"error":"invalid_grant"}
2021-02-10 22:02:27,772 - PixivUtil20210108-beta4 - ERROR - Invalid grant_type parameter or parameter missing
2021-02-10 22:02:27,772 - PixivUtil20210108-beta4 - ERROR - NoneType: None

2021-02-10 22:02:27,788 - PixivUtil20210108-beta4 - ERROR - Error getting FANBOX artist by id: ninoseyasunori ==> Failed to login using OAuth
2021-02-10 22:02:27,788 - PixivUtil20210108-beta4 - ERROR - Traceback (most recent call last):
  File "C:\PixivUtil2\PixivFanboxHandler.py", line 19, in process_fanbox_artist_by_id
    artist = br.fanboxGetArtistById(artist_id)
  File "C:\PixivUtil2\PixivBrowserFactory.py", line 914, in fanboxGetArtistById
    self.getMemberInfoWhitecube(artist.artistId, pixivArtist)
  File "C:\PixivUtil2\PixivBrowserFactory.py", line 642, in getMemberInfoWhitecube
    login_response = self._oauth_manager.login()
  File "C:\PixivUtil2\PixivOAuth.py", line 238, in login
    raise PixivException("Failed to login using OAuth", PixivException.OAUTH_LOGIN_ISSUE)
PixivException.PixivException: 0 Failed to login using OAuth, hasDumpPage=N, pageData=None

but i can get authentication just fine with saved token... so i guess it's probably because your token had expired?

i think the oauth problem is not solved yet, as pixiv changed the api. some say it doesn't accept password now. but you could refer to this issue, i guess you can try to obtain the token manually. https://github.com/upbit/pixivpy/issues/158

bluerthanever commented 3 years ago

also... in pixivutil20210215-beta1, the method to get fanbox artist information should have been changed back to the way that doesn't require oauth already...?

akeboshiKOU commented 3 years ago

Obtaining 'refresh_token' manually worked! Thanks for the help!

Nandaka commented 3 years ago

@bluerthanever looks like it is being called from different place. Maybe I'll modify the getMemberInfoWhitecube() so it also bypass the oAuth.

EDIT: is it called from getMemberPage()' which will callgetMemberInfoWhitecube()` if there is no reference image id...

Nandaka commented 3 years ago

need different API just to get the member token (user_account) and background (background_image_url)

EDIT:

bluerthanever commented 3 years ago

EDIT: is it called from getMemberPage()' which will call getMemberInfoWhitecube()` if there is no reference image id...

had never noticed this before... and looks like there's another similar issue.

Nandaka commented 3 years ago

yeah, this specific for FANBOX artist that doesn't have any images in the pixiv profile => then it will encounter this issue to get the user_account (member_token) information. If they have at least 1 image, then different API will be used.

nazhendenb commented 3 years ago

Did you have sloved it? The same question is happening to me today.

Nandaka commented 3 years ago

no automated way to do it, need to do it manually by following the method described in https://gist.github.com/ZipFile/c9ebedb224406f4f11845ab700124362