当前位置: 首页>>代码示例>>Python>>正文


Python Pocket.get_credentials方法代码示例

本文整理汇总了Python中pocket.Pocket.get_credentials方法的典型用法代码示例。如果您正苦于以下问题:Python Pocket.get_credentials方法的具体用法?Python Pocket.get_credentials怎么用?Python Pocket.get_credentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocket.Pocket的用法示例。


在下文中一共展示了Pocket.get_credentials方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post_linkPocket

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_credentials [as 别名]
def post_linkPocket():
    uid = request.headers.get('Authorization')
    content = request.get_json()
    request_token = content['code']
    if uid is None:
        print "WTF uid is none on linkPocket"

    user_credentials = Pocket.get_credentials(consumer_key=CONSUMER_KEY, code=request_token)
    secret = user_credentials['access_token']
    accounts.set_secret(uid, secret)
    return 'OK'
开发者ID:mllobet,项目名称:kenobi-server,代码行数:13,代码来源:server.py

示例2: authorize

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_credentials [as 别名]
def authorize():
    request_token = WF.cached_data('pocket_request_token')
    if request_token:
        try:
            user_credentials = Pocket.get_credentials(
                consumer_key=config.CONSUMER_KEY,
                code=request_token
            )
            WF.save_password(
                'pocket_access_token',
                user_credentials['access_token']
            )
            # We don't need the cache anymore. Clear it for security reasons
            WF.clear_cache()
        except RateLimitException:
            WF.logger.error('RateLimitException')
开发者ID:hbcbh1999,项目名称:alfred-pocket,代码行数:18,代码来源:pocket_alfred.py

示例3: get_auth

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_credentials [as 别名]
def get_auth(conf_file):

    request_token = Pocket.get_request_token(consumer_key=consumer_key, redirect_uri=redirect_uri)

# URL to redirect user to, to authorize your app
    auth_url = Pocket.get_auth_url(code=request_token, redirect_uri=redirect_uri)
    print """Please visit this URL to autorize the application:

        %s

    You've got 60 seconds.""" % auth_url

    time.sleep(60)

    user_credentials = Pocket.get_credentials(consumer_key=consumer_key, code=request_token)
    access_token = user_credentials['access_token']

    cfg = SafeConfigParser()
    cfg.add_section('pocket')
    cfg.set('pocket', 'access_token', access_token)
    cfg.set('pocket', 'consumer_key', consumer_key)
    with open(conf_file) as dest:
        cfg.write(dest)
开发者ID:funollet,项目名称:pocketcli,代码行数:25,代码来源:get_auth.py

示例4: auth

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_credentials [as 别名]
def auth():
	# Pulls request token from session, deletes
	if 'request_token' in session:
		request_token = session['request_token']
		session.pop('request_token', None)
	# Authenticates user via Pocket API
	# Grabs both Pocket username and API access token to store in DB
	credentials = Pocket.get_credentials(consumer_key=CONSUMER_KEY, code=request_token)
	token = credentials['access_token']
	username = credentials['username']
	# If access token is received, redirect back to login
	if token is None or token == "":
		flash('Login Failed! Please try again.')
		return redirect(url_for('login'))
	# Creates user if one doesn't already exist w/ the username + access token pair
	user = User.query.filter_by(username = username).first()
	if user is None:
		user = User(username = username, token = token, role = ROLE_USER)
		db.session.add(user)
		db.session.commit()
	# Logs in user and redirects back to index!
	login_user(user)
	return redirect(request.args.get('next') or url_for('home'))
开发者ID:bceskavich,项目名称:bulletin,代码行数:25,代码来源:views.py

示例5: print

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_credentials [as 别名]
from pocket import Pocket

request_token = Pocket.get_request_token("44479-ea92cc886eed9b46660b84a4")
print(request_token)

# URL to redirect user to, to authorize your app
auth_url = Pocket.get_auth_url(request_token)
print(auth_url)

user_credentials = Pocket.get_credentials("44479-ea92cc886eed9b46660b84a4", request_token)
print(user_credentials)

access_token = user_credentials['access_token']
print(access_token)
开发者ID:MaxenceG2M,项目名称:pocketmon,代码行数:16,代码来源:get_token.py

示例6:

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_credentials [as 别名]
#!/usr/bin/env python3

import sys

from pocket import Pocket

consumer_key = sys.argv[1]

redirect_uri = "http://tumbolia.org/"

request_token = Pocket.get_request_token(
    consumer_key=consumer_key, redirect_uri=redirect_uri)

auth_url = Pocket.get_auth_url(
    code=request_token, redirect_uri=redirect_uri)

user_credentials = Pocket.get_credentials(
    consumer_key=consumer_key, code=request_token)

print(user_credentials['access_token'])
开发者ID:nslater,项目名称:random-pocket,代码行数:22,代码来源:auth.py

示例7: get_pocket_instance

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_credentials [as 别名]
def get_pocket_instance():
    user_credentials = Pocket.get_credentials(consumer_key = get_consumer_key(), code = get_request_token())
    access_token = user_credentials['access_token']
    pocket = Pocket(get_consumer_key(), access_token)

    return pocket
开发者ID:kchnr,项目名称:getpocket-to-epub,代码行数:8,代码来源:pocket_utils.py

示例8: raw_input

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_credentials [as 别名]
from datetime import datetime

# Open database, creating it if necessary.
db = dbm.open('cache', 'c')
if not "access_token" in db :
	request_token = Pocket.get_request_token(consumer_key=config.consumer_key, redirect_uri=config.redirect_uri)
	db["request_token"] = request_token
	print 'request_token ' + db["request_token"]

	# URL to redirect user to, to authorize your app
	auth_url = Pocket.get_auth_url(code=db["request_token"], redirect_uri=config.redirect_uri)
	print 'Go to ' + auth_url + " to authorize the script on your pocket account"
	i = raw_input("Press Enter to continue...")

	try:
		user_credentials = Pocket.get_credentials(consumer_key=config.consumer_key, code=db["request_token"])
	except pocket.RateLimitException, e:
		print "Unable to auth..." + str(e)
		db.close()
		exit(1)
	db["access_token"] = user_credentials["access_token"]

pocket_instance = pocket.Pocket(config.consumer_key, db["access_token"])


stream = open('feeds.yaml', 'r')
feeds = yaml.load(stream)

for feed in feeds['feeds']:
    if not 'url' in feed:
        print str(feed) + " Seems to have no url..."
开发者ID:moadibfr,项目名称:MyFeedToPocket,代码行数:33,代码来源:app.py

示例9: get

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_credentials [as 别名]
 def get(self, request, *args, **kwargs):
     user_credentials = Pocket.get_credentials(
         consumer_key=settings.CONSUMER_KEY, code=request.session.get('request_token')
     )
     request.session['access_token'] = user_credentials['access_token']
     return redirect('home')
开发者ID:Undauted,项目名称:Practice-getpocket,代码行数:8,代码来源:views.py


注:本文中的pocket.Pocket.get_credentials方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。