本文整理汇总了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'
示例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')
示例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)
示例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'))
示例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)
示例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'])
示例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
示例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..."
示例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')