Skip to main content

Get your Pixiv token (for running upbit/pixivpy)

Project description

gppt: get-pixivpy-token

PyPI ghcr Maintainability pre-commit.ci status

Install

pip install gppt

Enable Proxy

Set ALL_PROXY or HTTPS_PROXY to your environment variables.

Run

Example

from gppt import GetPixivToken
from pixivpy3 import AppPixivAPI

def get_refresh_token() -> str:
    with open("token.txt", "w+") as f:
        if refresh_token := f.read().strip():
            return refresh_token

        g = GetPixivToken(headless=True)
        refresh_token = g.login(username="...", password="...")["refresh_token"]
        f.write(refresh_token)
        return refresh_token

aapi = 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: 3600

From CLI

  • Note: 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: 3600

From Library

  • Note: In advance, please setup google-chrome-stable + selenium + webdriver If either username or password are missing, manual input will be required.
from gppt import GetPixivToken

g = GetPixivToken(headless=False,username=None,password=None)
res = g.login(headless=None,username=None,password=None)
  • res.response returns:
{
  "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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gppt-4.0.1.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

gppt-4.0.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file gppt-4.0.1.tar.gz.

File metadata

  • Download URL: gppt-4.0.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.0 Linux/6.2.0-1019-azure

File hashes

Hashes for gppt-4.0.1.tar.gz
Algorithm Hash digest
SHA256 97a5a1ff244c2be607b437bced1f3ffff6ffbf35866d2114a38a0c73beac195c
MD5 e0e5a95a73db3124d185b68a448bcb24
BLAKE2b-256 980ab9f77f4a496c49ed4543bf7fa1a3045c1f8f20352a6a28a10fa0b968d4b5

See more details on using hashes here.

File details

Details for the file gppt-4.0.1-py3-none-any.whl.

File metadata

  • Download URL: gppt-4.0.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.0 Linux/6.2.0-1019-azure

File hashes

Hashes for gppt-4.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bc1b28c00c64e253eb3881137e39cc907c522f0cfe58f4b3fbdde432624c638e
MD5 b361f8ec1dd187065b468673d5b828ba
BLAKE2b-256 ec3d314e0e7a28bc4e1d94ed2fae4440b92743e82c20ebb28fd16cc76a809eab

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page