コード例 #1
0
ファイル: note4st_douban.py プロジェクト: pk13610/ts-plugin
class Note4stDouban:
    def __init__(self, user_json_file=None):
        """douban client for note4st
              user_json_file - solved on register
        """
        self.client = None
        self.user = DoubanUser()
        self.is_login = False
        if user_json_file:
            self.user.load(open(user_json_file))

    def register(self, auth_code):
        """douban client for note4st
              user_json_file - solved on register
        """
        self.client = DoubanClient(KEY, SECRET, CALLBACK, SCOPE)
        self.client.auth_with_code(auth_code)
        self.user.registered(
            self.client.user.me,
            self.client.user.access_token.token,
            self.client.user.access_token.refresh_token,
            self.client.user.access_token.expires_in,
            self.client.user.access_token.expires_at,
        )
        self.user.save2file(self.user.name)
        self.is_login = True

    def login(self, email=None, password=None, token=None):
        if not self.client:
            self.client = DoubanClient(KEY, SECRET, CALLBACK, SCOPE)
        if token:
            self.client.auth_with_token(token)
            self.client.auth_with_token(token)
        else:
            self.client.auth_with_password(email, password)
            self.user.refresh_token = self.client.refresh_token_code
        self.user.uid = self.client.user.me['uid']
        self.is_login = True
コード例 #2
0
ファイル: sdk.py プロジェクト: visaxin/graduate_book_sell
#!/usr/bin/env python
# encoding: utf-8

from douban_client import DoubanClient
from ruamel import yaml
import logging
import threading

API_KEY = ''
API_SECRET = ''

SCOPE = 'douban_basic_common,shuo_basic_r,shuo_basic_w,book_basic_r'

client = DoubanClient(API_KEY, API_SECRET, '', SCOPE)
client.auth_with_password('', '')

logger = logging.getLogger(__file__)
con = threading.Condition()
sdk_count = 0


def getClient():
    return client


def getBookByIsbn(isbn):
    return client.book.isbn(isbn)


def getBookById(id):
    logger
コード例 #3
0
from douban_client import DoubanClient

KEY = ''
SECRET = ''
CALLBACK = ''

SCOPE = 'douban_basic_common,community_basic_user'
client = DoubanClient(KEY, SECRET, CALLBACK, SCOPE)

client.auth_with_password('user_email', 'user_password')
print client.user.me
コード例 #4
0
ファイル: sdk.py プロジェクト: visaxin/graduate_book_sell
#!/usr/bin/env python
# encoding: utf-8


from douban_client import DoubanClient
from ruamel import yaml
import logging
import threading

API_KEY = ''
API_SECRET = ''

SCOPE = 'douban_basic_common,shuo_basic_r,shuo_basic_w,book_basic_r'

client = DoubanClient(API_KEY, API_SECRET, '', SCOPE)
client.auth_with_password('', '')

logger = logging.getLogger(__file__)
con = threading.Condition()
sdk_count = 0

def getClient():
    return client


def getBookByIsbn(isbn):
    return client.book.isbn(isbn)


def getBookById(id):
    logger
コード例 #5
0
#encoding:utf-8

"""
auth with password

注意:auth_with_password 需要先申请 xAuth 权限

关于 xAuth 权限申请可咨询: api-master[at]douban.com
或者到 http://www.douban.com/group/dbapi/ 寻求帮助

"""

from douban_client import DoubanClient

KEY = ''
SECRET = ''
CALLBACK = ''
SCOPE = 'douban_basic_common,community_basic_user'

client = DoubanClient(KEY, SECRET, CALLBACK, SCOPE)
client.auth_with_password('user_email', 'user_password')

print client.user.me