Skip to main content

Wechat Access Token Module for Python.

Installation

pip install pyqywe-token

Usage

MemoryStorage:

Token::

    # Sandbox: http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login
    In [1]: from pyqywe_token import Token

    In [2]: token = Token('wx7aad305aed68bfe3', '9eac636765940ec286055c559ff84039')

    In [3]: token.
    token.API_DOMAIN           token.access_info_key      token.expires_at           token.storage
    token.OPEN_DOMAIN          token.access_token         token.get                  token.token
    token.WECHAT_ACCESS_TOKEN  token.appid                token.secret

    In [3]: token.access_token()
    Out[3]: u'ZhvSop2FJxAEyRLjyMIQfcfUS1tG76wGEz6hc-qgRFjaWqnLscdYBRBXVhH-SyiwXpeYTu-LfU2Fj4dTVVE3s-35MhVeaWbUMXmS3lPXgD4yrl8287yfmIXAseZI55_xUOQdADAEYA'


access_token::

    In [1]: from pyqywe_token import access_token

    In [2]: access_token('wx7aad305aed68bfe3', '9eac636765940ec286055c559ff84039')
    Out[2]: u'ysR7_hUtodKCF1nHjq8gFtagugB8oEOlK6hB6raMztveawVzpnqK2FtftbQGsczTj0h2kc1Gl8R7fjmGVPmXBp306WW8UZUteXqiOgxh3DL0usLRLQVRn56Oi-yigkSoSYNbAIAEKZ'

RedisStorage:

Token::

    In [1]: import redis_extensions as redis

    In [2]: r = redis.StrictRedisExtensions(host='localhost', port=6379, db=0)

    In [3]: from pywe_storage import RedisStorage

    In [4]: storage = RedisStorage(r)

    In [5]: from pyqywe_token import Token

    In [6]: token = Token('wx7aad305aed68bfe3', '9eac636765940ec286055c559ff84039', storage=storage)

    In [7]: token.access_token()
    Out[7]: u'5kJwbClb1CBo-5Dz_a9hZp6x_6tyDD2NnVe8mBckiv4QhB4iq13gwrplWY1fbnAE8Te_za3p6hyiJ4vG1A-hapM5PDv3PEBBIB445oxv3dShVDBXqORbCnwT37zXwEDDSITbAEANDO'

    In [8]: r.get('pywe:wx7aad305aed68bfe3:access:info')
    Out[8]: '{"access_token": "5kJwbClb1CBo-5Dz_a9hZp6x_6tyDD2NnVe8mBckiv4QhB4iq13gwrplWY1fbnAE8Te_za3p6hyiJ4vG1A-hapM5PDv3PEBBIB445oxv3dShVDBXqORbCnwT37zXwEDDSITbAEANDO", "expires_in": 7200, "expires_at": 1485104793}'


access_token::

    In [1]: import redis_extensions as redis

    In [2]: r = redis.StrictRedisExtensions(host='localhost', port=6379, db=0)

    In [3]: from pywe_storage import RedisStorage

    In [4]: storage = RedisStorage(r)

    In [5]: from pyqywe_token import access_token

    In [6]: access_token('wx7aad305aed68bfe3', '9eac636765940ec286055c559ff84039', storage=storage)
    Out[6]: u'5kJwbClb1CBo-5Dz_a9hZi1GcqSnLkRV2aYFmjSBTGEvVrH81XhT2eUjunVSJn_ej2uFXLJarjC0dlI78r-HxCWtTNxSPC06ARG_QqE9FoP7VhJNFsPX5z7tsySsCyEgKEZbAIAGAV'

    In [7]: r.get('pywe:wx7aad305aed68bfe3:access:info')
    Out[7]: '{"access_token": "5kJwbClb1CBo-5Dz_a9hZp6x_6tyDD2NnVe8mBckiv4QhB4iq13gwrplWY1fbnAE8Te_za3p6hyiJ4vG1A-hapM5PDv3PEBBIB445oxv3dShVDBXqORbCnwT37zXwEDDSITbAEANDO", "expires_in": 7200, "expires_at": 1485104793}'

Method

class BaseToken(BaseWechat):
    def __init__(self, appid=None, secret=None, token=None, storage=None, token_fetched_func=None):

class Token(BaseToken):
    def __init__(self, appid=None, secret=None, storage=None, token_fetched_func=None):
        super(Token, self).__init__(appid=appid, secret=secret, storage=storage, token_fetched_func=token_fetched_func)

def access_token(self, appid=None, secret=None, storage=None, token_fetched_func=None):

def refresh_access_token(self, appid=None, secret=None, storage=None, token_fetched_func=None):

def final_access_token(self, cls, appid=None, secret=None, token=None, storage=None, token_fetched_func=None):

Metadata

Release files for pyqywe-token 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyqywe-token 1.0.0
File Size Uploaded Provenance Actions
pyqywe-token-1.0.0.tar.gz 3.7 kB Without provenance Details for pyqywe-token-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyqywe-token 1.0.0
File Interpreter ABI Platform Actions
pyqywe_token-1.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for pyqywe_token-1.0.0-py2.py3-none-any.whl

Total release size: 8.2 kB

Release files / pyqywe-token-1.0.0.tar.gz

Download URL pyqywe-token-1.0.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7a01beb3f8732196ab5ae8413cb67fff3bbe6551f9560ae046dc7157e9598c63
BLAKE2b-256 checksum
How to use checksums
cdef25e8aa5b1a07c1fb7d4bafe792f9afaa27920d07a656f4388fe7e477f13b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

Release files / pyqywe_token-1.0.0-py2.py3-none-any.whl

Download URL pyqywe_token-1.0.0-py2.py3-none-any.whl
Size 4.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
15c3e12d5d202265caf3f057d2a40f8f40a68b1edc9b7e8adc09c315ff3e45bd
BLAKE2b-256 checksum
How to use checksums
d1c67e9c9e25f1d7d369ff7e4e6cbc953275c65d7895e2c8ca7a39ed372bd3c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.3

Security for pyqywe-token 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page