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


Python Pocket.get_request_token方法代码示例

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


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

示例1: dispatch

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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)
开发者ID:Undauted,项目名称:Practice-getpocket,代码行数:9,代码来源:views.py

示例2: get_client

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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)
开发者ID:uranther,项目名称:kipy,代码行数:30,代码来源:pocket.py

示例3: get_request_token

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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
开发者ID:kchnr,项目名称:getpocket-to-epub,代码行数:10,代码来源:pocket_utils.py

示例4: connect_to_pocket

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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)
开发者ID:kodchi,项目名称:pocketfeed,代码行数:12,代码来源:views.py

示例5: pocket_login

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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))
开发者ID:Lothiraldan,项目名称:feedlight,代码行数:13,代码来源:app.py

示例6: auth

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [as 别名]
def auth():
    pocket = Pocket(config.POCKET_CONSUMER_KEY, config.BASE_URL +
            url_for('auth_callback'))
    try:
        code = pocket.get_request_token()
        url = pocket.get_authorize_url(code)
    except APIError as apie:
        return str(apie)
    session.pop('code', None)
    session['code'] = code
    return redirect(url)
开发者ID:c4pt0r,项目名称:pocket-bookmark,代码行数:13,代码来源:main.py

示例7: auth

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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
开发者ID:sidaga,项目名称:django-th,代码行数:17,代码来源:my_pocket.py

示例8: auth

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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
开发者ID:foxmask,项目名称:django-th,代码行数:18,代码来源:my_pocket.py

示例9: auth

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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
开发者ID:peterhunn,项目名称:django-th,代码行数:20,代码来源:my_pocket.py

示例10: login

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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)
开发者ID:bceskavich,项目名称:bulletin,代码行数:22,代码来源:views.py

示例11: main

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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()
开发者ID:Perlence,项目名称:youtube-to,代码行数:40,代码来源:pocket.py

示例12: gettoken

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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 ""
开发者ID:aquatix,项目名称:pocketstats,代码行数:25,代码来源:pocketstats.py

示例13: get_auth

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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

示例14:

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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

示例15: handle_data

# 需要导入模块: from pocket import Pocket [as 别名]
# 或者: from pocket.Pocket import get_request_token [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])
开发者ID:maxter2323,项目名称:Python-Small-Examples,代码行数:32,代码来源:chromeToPocket.py


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