Package: gppt
gppt: get-pixivpy-tokenGet your Pixiv token (for runningupbit/pixivpy)Refinepixiv_auth.py+its forkInstallpipinstallgpptEnable ProxySetALL_PROXYorHTTPS_PROXYto your environment variables.RunExamplefromgpptimportGetPixivTokenfrompixivpy3importAppPixivAPIdefget_refresh_token()->str:withopen("token.txt","w+")asf:ifrefresh_token:=f.read().strip():returnrefresh_tokeng=GetPixivToken(headless=True)refresh_token=g.login(username="...",password="...")["refresh_token"]f.write(refresh_token)returnrefresh_tokenaapi=AppPixivAPI()aapi.auth(refresh_token=get_refresh_token())...From Docker$ docker run --rm -it ghcr.io/eggplants/get-pixivpy-token lh -u <id> -p <pw>
[+]: Success!
access_token: ***
refresh_token: ***
expires_in: 3600From CLINote:In advance, please setup google-chrome-stable + selenium + webdriver# with browser
$ gppt login
[!]: Chrome browser will be launched. Please login.
(Log in to Pixiv from the login screen that starts up.)
[+]: Success!
access_token: ***
refresh_token: ***
expires_in: 3600
...

# with headless browser
$ gppt login-headless -u <id> -p <pw>
[!]: Chrome browser will be launched. Please login.
[+]: Success!
access_token: ***
refresh_token: ***
expires_in: 3600From LibraryNote:In advance, please setup google-chrome-stable + selenium + webdriverIf either username or password are missing, manual input will be required.fromgpptimportGetPixivTokeng=GetPixivToken(headless=False,username=None,password=None)res=g.login(headless=None,username=None,password=None)res.responsereturns:{"access_token":"***","expires_in":3600,"refresh_token":"***","scope":"","token_type":"bearer","user":{"account":"***","id":"***","is_mail_authorized":<bool>,"is_premium":<bool>,"mail_address":"***@***","name":"***","profile_image_urls":{"px_16x16":"https://s.pximg.net/common/images/no_profile_ss.png","px_170x170":"https://s.pximg.net/common/images/no_profile.png","px_50x50":"https://s.pximg.net/common/images/no_profile_s.png"},"require_policy_agreement":<bool>,"x_restrict":2}}Help$ gppt -h
usage: gppt [-h]
            {login,l,login-interactive,li,login-headless,lh,refresh,r} ...

Get your Pixiv token (for running upbit/pixivpy)

positional arguments:
  {login,l,login-interactive,li,login-headless,lh,refresh,r}
    login (l)           retrieving auth token
    login-interactive (li)
                        `login` in interactive mode
    login-headless (lh)
                        `login` in headless mode
    refresh (r)         refresh tokens

optional arguments:
  -h, --help            show this help message and exit$ gppt l -h
usage: gppt login [-h] [-u USERNAME] [-p PASSWORD] [-j]

optional arguments:
  -h, --help            show this help message and exit
  -u USERNAME, --username USERNAME
                        your E-mail address / pixiv ID
  -p PASSWORD, --password PASSWORD
                        your current pixiv password
  -j, --json            output response as json$ gppt li -h
usage: gppt login-interactive [-h] [-j]

optional arguments:
  -h, --help  show this help message and exit
  -j, --json  output response as json$ gppt lh -h
usage: gppt login-headless [-h] -u USERNAME -p PASSWORD [-j]

optional arguments:
  -h, --help            show this help message and exit
  -u USERNAME, --username USERNAME
                        your E-mail address / pixiv ID
  -p PASSWORD, --password PASSWORD
                        your current pixiv password
  -j, --json            output response as json$ gppt r -h
usage: gppt refresh [-h] [-j] refresh_token

positional arguments:
  refresh_token

optional arguments:
  -h, --help     show this help message and exit
  -j, --json     output response as json