本文整理汇总了Python中pocket.Pocket.get_auth_url方法的典型用法代码示例。如果您正苦于以下问题:Python Pocket.get_auth_url方法的具体用法?Python Pocket.get_auth_url怎么用?Python Pocket.get_auth_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocket.Pocket
的用法示例。
在下文中一共展示了Pocket.get_auth_url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dispatch
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
def dispatch(self, request, *args, **kwargs):
if not request.session.get('access_token'):
request_token = Pocket.get_request_token(consumer_key=settings.CONSUMER_KEY)
request.session['request_token'] = request_token
auth_url = Pocket.get_auth_url(code=request_token, redirect_uri='http://localhost:8000/token')
return HttpResponseRedirect(auth_url)
return super(HomeView, self).dispatch(request, *args, **kwargs)
示例2: get_client
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
def get_client(self):
"""
Connects to Pocket API using OAuth
"""
request_token = pckt.get_request_token(
consumer_key=self.consumer_key,
redirect_uri=self.REDIRECT_URI
)
log.debug(request_token)
# URL to redirect user to, to authorize your app
auth_url = pckt.get_auth_url(
code=request_token,
redirect_uri=self.REDIRECT_URI
)
log.debug(auth_url)
# only needed to authorize your app the first time
#request_token2 = input('request token: ')
if not self.access_token:
self.access_token = pckt.get_access_token(
consumer_key=self.consumer_key, code=request_token)
log.debug(self.access_token)
return pckt(
consumer_key=self.consumer_key,
access_token=self.access_token)
示例3: get_request_token
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
def get_request_token():
consumer_key = get_consumer_key()
request_token = Pocket.get_request_token(consumer_key = consumer_key)
auth_url = Pocket.get_auth_url(code=request_token)
os.system('open "{0}"'.format(auth_url))
time.sleep(5)
return request_token
示例4: connect_to_pocket
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
def connect_to_pocket(request):
redirect_uri = request.build_absolute_uri(reverse('feed_pocket_success'))
request_token = Pocket.get_request_token(
consumer_key=settings.POCKET_CONSUMER_KEY,
redirect_uri=redirect_uri)
auth_url = Pocket.get_auth_url(code=request_token,
redirect_uri=redirect_uri)
request.user.profile.pocket_request_token = request_token
request.user.profile.save()
return HttpResponseRedirect(auth_url)
示例5: pocket_login
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
def pocket_login():
"""Calling into authorize will cause the OpenID auth machinery to kick
in. When all worked out as expected, the remote application will
redirect back to the callback URL provided.
"""
redirect_uri = url_for('pocket_authorized', _external=True)
request_token = Pocket.get_request_token(consumer_key=POCKET_APP_TOKEN,
redirect_uri=redirect_uri)
session['request_token'] = request_token
return redirect(Pocket.get_auth_url(code=request_token,
redirect_uri=redirect_uri))
示例6: auth
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
def auth(self, request):
"""
let's auth the user to the Service
"""
callback_url = "http://%s%s" % (request.get_host(), reverse("pocket_callback"))
request_token = Pocket.get_request_token(consumer_key=self.consumer_key, redirect_uri=callback_url)
# Save the request token information for later
request.session["request_token"] = request_token
# URL to redirect user to, to authorize your app
auth_url = Pocket.get_auth_url(code=request_token, redirect_uri=callback_url)
return auth_url
示例7: auth
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
def auth(self, request):
"""
let's auth the user to the Service
:param request: request object
:return: callback url
:rtype: string that contains the url to redirect after auth
"""
callback_url = self.callback_url(request)
request_token = Pocket.get_request_token(consumer_key=self.consumer_key, redirect_uri=callback_url)
# Save the request token information for later
request.session['request_token'] = request_token
# URL to redirect user to, to authorize your app
auth_url = Pocket.get_auth_url(code=request_token, redirect_uri=callback_url)
return auth_url
示例8: auth
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
def auth(self, request):
"""
let's auth the user to the Service
"""
callback_url = self.callback_url(request, 'pocket')
request_token = Pocket.get_request_token(
consumer_key=self.consumer_key,
redirect_uri=callback_url)
# Save the request token information for later
request.session['request_token'] = request_token
# URL to redirect user to, to authorize your app
auth_url = Pocket.get_auth_url(
code=request_token, redirect_uri=callback_url)
return auth_url
示例9: login
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
def login():
# If user is already logged in, simply redirect to index
if g.user is not None and g.user.is_authenticated():
return redirect(url_for('home'))
# Load login if not logged in
else:
if os.environ.get('HEROKU') is None:
url_prefix = 'http://localhost:5000/'
else:
url_prefix = 'http://bulletin.herokuapp.com/'
form = LoginForm()
if form.validate_on_submit():
# Grabs request token from Pocket and stores in session for later authentication
request_token = Pocket.get_request_token(consumer_key=CONSUMER_KEY, redirect_uri=url_prefix + 'auth')
session['request_token'] = request_token
# Grabs auth url from Pocket to redirect user to
auth_url = Pocket.get_auth_url(code=request_token, redirect_uri=url_prefix + 'auth')
return redirect(auth_url)
return render_template('index.html',
form = form)
示例10: main
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
def main():
creds = client.OAuth2Credentials(
config.YOUTUBE_ACCESS_TOKEN, config.YOUTUBE_CLIENT_ID,
config.YOUTUBE_CLIENT_SECRET, config.YOUTUBE_REFRESH_TOKEN,
arrow.get(config.YOUTUBE_TOKEN_EXPIRY),
config.YOUTUBE_TOKEN_URI, config.YOUTUBE_USER_AGENT)
if creds.token_expiry <= arrow.get():
creds.refresh(Http())
config.YOUTUBE_ACCESS_TOKEN = creds.access_token
config.YOUTUBE_TOKEN_EXPIRY = creds.token_expiry.isoformat()
config.save()
http = authorized_http(creds)
youtube = build('youtube', 'v3', http=http())
if not config.POCKET_ACCESS_TOKEN:
import webbrowser
request_token = Pocket.get_request_token(config.POCKET_CONSUMER_KEY)
auth_url = Pocket.get_auth_url(request_token)
webbrowser.open(auth_url)
raw_input('Press ENTER when done ')
access_token = Pocket.get_access_token(config.POCKET_CONSUMER_KEY,
request_token)
config.POCKET_ACCESS_TOKEN = access_token
config.save()
pocket = Pocket(config.POCKET_CONSUMER_KEY, config.POCKET_ACCESS_TOKEN)
playlists = youtube.playlists().list(part='snippet', mine=True).execute()
favorites = next((item for item in playlists['items']
if item['snippet']['title'] == 'Favorites'), None)
req = youtube.playlistItems().list(part='snippet',
playlistId=favorites['id'])
pool = Pool()
while req:
res = req.execute()
for item in res['items']:
pool.spawn(put_in_pocket, youtube, http, pocket, item)
req = youtube.playlistItems().list_next(req, res)
pool.join()
示例11: gettoken
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
def gettoken(consumer_key):
"""
Get access token
"""
# URL to redirect user to, to authorize your app
redirect_uri = 'https://github.com/aquatix/pocketstats'
try:
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)
except pocket.RateLimitException as e:
# pocket.RateLimitException: User was authenticated, but access denied due to lack of permission or rate limiting. Invalid consumer key.
print "Failed to get an access token, likely due to an invalid consumer key"
print "Go to https://getpocket.com/developer/ and generate a key there"
print
print "Error was:"
print e
print ""
sys.exit(1)
print "Open the uri printed below in your browser and allow the application"
print "Note the key you get in response, as that is your access_token"
print ""
print auth_url
print ""
示例12: get_auth
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [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)
示例13: print
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [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)
示例14: handle_data
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
for attr in attrs:
if attr[0] == linkTag:
link = attr[1]
print "link: ", link
newPair = [link, currentTag]
urlList.append(newPair)
def handle_data(self, data):
if self.readData:
print "Tag: ", data
currentTag = data
self.readData = False
request_token = Pocket.get_request_token(consumer_key, redirect_uri)
auth_url = Pocket.get_auth_url(request_token,redirect_uri)
webbrowser.open_new_tab(auth_url)
print 'Please authorize the app using the following url and press ENTER here', auth_url
raw_input()
access_token = Pocket.get_access_token(consumer_key=consumer_key, code=request_token)
print 'Got request token', request_token
print 'Got access token', access_token
def add_url(url, tag):
print 'adding', url
pocket_instance = Pocket(consumer_key, access_token)
print pocket_instance.add(url=url, tags=[tag])
示例15: Pocket
# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_auth_url [as 别名]
from pocket import Pocket
ckey = '47167-9324a229a155827bc214aa2a'
redir = 'http://google.com'
request_token = Pocket.get_request_token(consumer_key=ckey, redirect_uri=redir)
# URL to redirect user to, to authorize your app
auth_url = Pocket.get_auth_url(code=request_token, redirect_uri=redir)
print(auth_url)
input()
user_credentials = Pocket.get_credentials(consumer_key=ckey, code=request_token)
access_token = user_credentials['access_token']
pocketi = Pocket(ckey, access_token)
for link in links[500:]:
pocketi.add(link)
import numpy as np
import matplotlib.pyplot as plt
xaxis = range(1,50)
plt.plot(xaxis, [np.sqrt(6*sum([1./n**2 for n in range(1,x)])) for x in xaxis])
plt.axhline(np.pi, color='r')
plt.show()z