本文整理汇总了Python中util.oauth_starter函数的典型用法代码示例。如果您正苦于以下问题:Python oauth_starter函数的具体用法?Python oauth_starter怎么用?Python oauth_starter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了oauth_starter函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: start_oauth_flow
def start_oauth_flow(self, feature):
starter = util.oauth_starter(
oauth_flickr.StartHandler, feature=feature
).to(
'/flickr/add', scopes='write' if feature == 'publish' else 'read'
)
return starter(self.request, self.response).post()
开发者ID:kylewm,项目名称:bridgy,代码行数:7,代码来源:flickr.py
示例2: finish_oauth_flow
def finish_oauth_flow(self, auth_entity, state):
"""Adds or deletes a FacebookPage, or restarts OAuth to get publish permissions.
Args:
auth_entity: FacebookAuth
state: encoded state string
"""
if auth_entity is None:
auth_entity_key = util.get_required_param(self, "auth_entity_key")
auth_entity = ndb.Key(urlsafe=auth_entity_key).get()
if state is None:
state = self.request.get("state")
state_obj = self.decode_state_parameter(state)
id = state_obj.get("id") or self.request.get("id")
if id and id != auth_entity.key.id():
auth_entity = auth_entity.for_page(id)
auth_entity.put()
source = self.maybe_add_or_delete_source(FacebookPage, auth_entity, state)
# If we were already signed up for publish, we had an access token with publish
# permissions. If we then go through the listen signup flow, we'll get a token
# with just the listen permissions. In that case, do the whole OAuth flow again
# to get a token with publish permissions again.
feature = state_obj.get("feature")
if source is not None and feature == "listen" and "publish" in source.features:
logging.info("Restarting OAuth flow to get publish permissions.")
source.features.remove("publish")
source.put()
start = util.oauth_starter(oauth_facebook.StartHandler, feature="publish", id=id)
restart = start.to("/facebook/oauth_handler", scopes=PUBLISH_SCOPES)
restart(self.request, self.response).post()
开发者ID:kylewm,项目名称:bridgy,代码行数:34,代码来源:facebook.py
示例3: post
def post(self):
features = self.request.get('feature')
features = features.split(',') if features else []
starter = util.oauth_starter(oauth_instagram.StartHandler).to(
'/instagram/oauth_callback',
# http://instagram.com/developer/authentication/#scope
scopes='likes comments' if 'publish' in features else None)
starter(self.request, self.response).post()
开发者ID:kylewm,项目名称:bridgy,代码行数:8,代码来源:instagram.py
示例4: post
def post(self):
features = self.request.get('feature')
features = features.split(',') if features else []
starter = util.oauth_starter(oauth_facebook.StartHandler).to(
'/facebook/oauth_handler', scopes=sorted(set(
(LISTEN_SCOPES if 'listen' in features else []) +
(PUBLISH_SCOPES if 'publish' in features else []))))
starter(self.request, self.response).post()
开发者ID:lcorbasson,项目名称:bridgy,代码行数:8,代码来源:facebook.py
示例5: post
def post(self):
# pass explicit 'write' instead of None for publish so that oauth-dropins
# (and tweepy) don't use signin_with_twitter ie /authorize. this works
# around a twitter API bug: https://dev.twitter.com/discussions/21281
access_type = ('read' if util.get_required_param(self, 'feature')
== 'listen' else 'write')
handler = util.oauth_starter(oauth_twitter.StartHandler).to(
'/twitter/add', access_type=access_type)(self.request, self.response)
return handler.post()
开发者ID:sanduhrs,项目名称:bridgy,代码行数:9,代码来源:twitter.py
示例6: post
def post(self):
features = self.request.get("feature")
features = features.split(",") if features else []
starter = util.oauth_starter(oauth_facebook.StartHandler).to(
"/facebook/oauth_handler",
scopes=sorted(
set((LISTEN_SCOPES if "listen" in features else []) + (PUBLISH_SCOPES if "publish" in features else []))
),
)
starter(self.request, self.response).post()
开发者ID:kylewm,项目名称:bridgy,代码行数:10,代码来源:facebook.py
示例7: post
def post(self):
ia_start = util.oauth_starter(indieauth.StartHandler).to('/instagram/callback')(
self.request, self.response)
try:
self.redirect(ia_start.redirect_url(me=util.get_required_param(self, 'user_url')))
except Exception as e:
if util.is_connection_failure(e) or util.interpret_http_exception(e)[0]:
self.messages.add("Couldn't fetch your web site: %s" % e)
return self.redirect('/')
raise
开发者ID:snarfed,项目名称:bridgy,代码行数:11,代码来源:instagram.py
示例8: start_oauth_flow
def start_oauth_flow(self, feature):
"""Redirects to Twitter's OAuth endpoint to start the OAuth flow.
Args:
feature: 'listen' or 'publish'
"""
features = feature.split(',') if feature else []
assert all(f in models.Source.FEATURES for f in features)
# pass explicit 'write' instead of None for publish so that oauth-dropins
# (and tweepy) don't use signin_with_twitter ie /authorize. this works
# around a twitter API bug: https://dev.twitter.com/discussions/21281
access_type = 'write' if 'publish' in features else 'read'
handler = util.oauth_starter(oauth_twitter.StartHandler, feature=feature).to(
'/twitter/add', access_type=access_type)(self.request, self.response)
return handler.post()
开发者ID:kylewm,项目名称:bridgy,代码行数:16,代码来源:twitter.py
示例9: finish_oauth_flow
def finish_oauth_flow(self, auth_entity, state):
"""Adds or deletes a :class:`FacebookPage`, or restarts OAuth to get publish
permissions.
Args:
auth_entity: :class:`oauth_dropins.facebook.FacebookAuth`
state: encoded state string
"""
if auth_entity is None:
auth_entity_key = self.request.get('auth_entity_key')
if auth_entity_key:
auth_entity = ndb.Key(urlsafe=auth_entity_key).get()
if state is None:
state = self.request.get('state')
state_obj = util.decode_oauth_state(state) if state else {}
id = state_obj.get('id') or self.request.get('id')
if id and auth_entity and id != auth_entity.key.id():
auth_entity = auth_entity.for_page(id)
if auth_entity:
auth_entity.put()
source = self.maybe_add_or_delete_source(FacebookPage, auth_entity, state)
# If we were already signed up for publish, we had an access token with publish
# permissions. If we then go through the listen signup flow, we'll get a token
# with just the listen permissions. In that case, do the whole OAuth flow again
# to get a token with publish permissions again.
feature = state_obj.get('feature')
if source is not None and feature == 'listen' and 'publish' in source.features:
logging.info('Restarting OAuth flow to get publish permissions.')
source.features.remove('publish')
source.put()
start = util.oauth_starter(oauth_facebook.StartHandler,
feature='publish', id=id)
restart = start.to('/facebook/oauth_handler', scopes=PUBLISH_SCOPES)
restart(self.request, self.response).post()
# ask the user for their web site if we don't already have one.
if source and not source.domains:
self.redirect('/edit-websites?' + urllib.urlencode({
'source_key': source.key.urlsafe(),
}))
开发者ID:snarfed,项目名称:bridgy,代码行数:44,代码来源:facebook.py
示例10: ConfirmSelfHosted
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write(template.render(
'templates/confirm_self_hosted_wordpress.html',
{'auth_entity_key': auth_entity.key.urlsafe(), 'state': state}))
return
self.maybe_add_or_delete_source(WordPress, auth_entity, state)
class ConfirmSelfHosted(util.Handler):
def post(self):
self.maybe_add_or_delete_source(
WordPress,
ndb.Key(urlsafe=util.get_required_param(self, 'auth_entity_key')).get(),
util.get_required_param(self, 'state'))
class SuperfeedrNotifyHandler(superfeedr.NotifyHandler):
SOURCE_CLS = WordPress
application = webapp2.WSGIApplication([
('/wordpress/start', util.oauth_starter(oauth_wordpress.StartHandler).to(
'/wordpress/add')),
('/wordpress/confirm', ConfirmSelfHosted),
# This handles both add and delete. (WordPress.com only allows a single
# OAuth redirect URL.)
('/wordpress/add', AddWordPress),
('/wordpress/notify/(.+)', SuperfeedrNotifyHandler),
], debug=appengine_config.DEBUG)
开发者ID:sanduhrs,项目名称:bridgy,代码行数:30,代码来源:wordpress_rest.py
示例11: AddFacebookPage
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write(
template.render('templates/choose_facebook.html', vars))
class AddFacebookPage(util.Handler):
def post(self):
state = util.get_required_param(self, 'state')
id = util.get_required_param(self, 'id')
auth_entity_key = util.get_required_param(self, 'auth_entity_key')
auth_entity = ndb.Key(urlsafe=auth_entity_key).get()
if id != auth_entity.key.id():
auth_entity = auth_entity.for_page(id)
auth_entity.put()
self.maybe_add_or_delete_source(FacebookPage, auth_entity, state)
application = webapp2.WSGIApplication([
# OAuth scopes are set in listen.html and publish.html
('/facebook/start', util.oauth_starter(oauth_facebook.StartHandler).to(
'/facebook/oauth_handler')),
('/facebook/oauth_handler', OAuthCallback),
('/facebook/add', AddFacebookPage),
('/facebook/delete/finish', oauth_facebook.CallbackHandler.to('/delete/finish')),
('/facebook/publish/start', oauth_facebook.StartHandler.to(
'/publish/facebook/finish')),
], debug=appengine_config.DEBUG)
开发者ID:priscila225,项目名称:bridgy,代码行数:30,代码来源:facebook.py
示例12: AddTumblr
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write(template.render('templates/choose_blog.html', vars))
class AddTumblr(util.Handler):
def post(self):
auth_entity_key = util.get_required_param(self, 'auth_entity_key')
self.maybe_add_or_delete_source(
Tumblr,
ndb.Key(urlsafe=auth_entity_key).get(),
util.get_required_param(self, 'state'),
blog_name=util.get_required_param(self, 'blog'),
)
class SuperfeedrNotifyHandler(superfeedr.NotifyHandler):
SOURCE_CLS = Tumblr
application = webapp2.WSGIApplication([
# Tumblr doesn't seem to use scope
# http://www.tumblr.com/docs/en/api/v2#oauth
('/tumblr/start', util.oauth_starter(oauth_tumblr.StartHandler).to(
'/tumblr/choose_blog')),
('/tumblr/choose_blog', ChooseBlog),
('/tumblr/add', AddTumblr),
('/tumblr/delete/finish', oauth_tumblr.CallbackHandler.to('/delete/finish')),
('/tumblr/notify/(.+)', SuperfeedrNotifyHandler),
], debug=appengine_config.DEBUG)
开发者ID:LennonFlores,项目名称:bridgy,代码行数:29,代码来源:tumblr.py
示例13: ConfirmSelfHosted
self.maybe_add_or_delete_source(WordPress, auth_entity, state)
class ConfirmSelfHosted(util.Handler):
def post(self):
self.maybe_add_or_delete_source(
WordPress,
ndb.Key(urlsafe=util.get_required_param(self, "auth_entity_key")).get(),
util.get_required_param(self, "state"),
)
class SuperfeedrNotifyHandler(superfeedr.NotifyHandler):
SOURCE_CLS = WordPress
application = webapp2.WSGIApplication(
[
# wordpress.com doesn't seem to use scope
# https://developer.wordpress.com/docs/oauth2/
("/wordpress/start", util.oauth_starter(oauth_wordpress.StartHandler).to("/wordpress/add")),
("/wordpress/confirm", ConfirmSelfHosted),
# This handles both add and delete. (WordPress.com only allows a single
# OAuth redirect URL.)
("/wordpress/add", AddWordPress),
("/wordpress/notify/(.+)", SuperfeedrNotifyHandler),
],
debug=appengine_config.DEBUG,
)
开发者ID:snarfed,项目名称:bridgy,代码行数:29,代码来源:wordpress_rest.py
示例14: super
"""
return super(GooglePlusPage, self).canonicalize_syndication_url(
util.follow_redirects(url).url)
class OAuthCallback(util.Handler):
"""OAuth callback handler.
Both the add and delete flows have to share this because Google+'s
oauth-dropin doesn't yet allow multiple callback handlers. :/
"""
def get(self):
auth_entity_str_key = util.get_required_param(self, 'auth_entity')
state = self.request.get('state')
if not state:
# state doesn't currently come through for G+. not sure why. doesn't
# matter for now since we don't plan to implement publish for G+.
state = self.construct_state_param_for_add(feature='listen')
auth_entity = ndb.Key(urlsafe=auth_entity_str_key).get()
self.maybe_add_or_delete_source(GooglePlusPage, auth_entity, state)
application = webapp2.WSGIApplication([
# OAuth scopes are set in listen.html and publish.html
('/googleplus/start', util.oauth_starter(oauth_googleplus.StartHandler).to(
'/googleplus/oauth2callback')),
('/googleplus/oauth2callback', oauth_googleplus.CallbackHandler.to('/googleplus/add')),
('/googleplus/add', OAuthCallback),
('/googleplus/delete/start', oauth_googleplus.StartHandler.to('/googleplus/oauth2callback')),
], debug=appengine_config.DEBUG)
开发者ID:dev511,项目名称:bridgy,代码行数:30,代码来源:googleplus.py
示例15: OAuthStartHandler
sent=['http://a/link'],
)]
class OAuthStartHandler(oauth_handlers.StartHandler):
"""Stand-in for the oauth-dropins StartHandler, redirects to
a made-up silo url
"""
def redirect_url(self, state=None):
logging.debug('oauth handler redirect')
return 'http://fake/auth/url?' + urllib.urlencode({
'redirect_uri': self.to_url(state),
})
FakeStartHandler = util.oauth_starter(OAuthStartHandler).to('/fakesource/add')
class FakeAddHandler(util.Handler):
"""Handles the authorization callback when handling a fake source
"""
auth_entity = FakeAuthEntity(user_json=json.dumps({
'id': '0123456789',
'name': 'Fake User',
'url': 'http://fakeuser.com/',
}))
@staticmethod
def with_auth(auth):
class HandlerWithAuth(FakeAddHandler):
auth_entity = auth
开发者ID:snarfed,项目名称:bridgy,代码行数:31,代码来源:testutil.py
示例16: OAuthCallback
class OAuthCallback(util.Handler):
"""OAuth callback handler.
Both the add and delete flows have to share this because Google+'s
oauth-dropin doesn't yet allow multiple callback handlers. :/
"""
def get(self):
auth_entity_str_key = util.get_required_param(self, "auth_entity")
state = self.request.get("state")
if not state:
# state doesn't currently come through for G+. not sure why. doesn't
# matter for now since we don't plan to implement publish for G+.
state = self.construct_state_param_for_add(feature="listen")
auth_entity = ndb.Key(urlsafe=auth_entity_str_key).get()
self.maybe_add_or_delete_source(GooglePlusPage, auth_entity, state)
application = webapp2.WSGIApplication(
[
# OAuth scopes are set in listen.html and publish.html
("/googleplus/start", util.oauth_starter(oauth_googleplus.StartHandler).to("/googleplus/oauth2callback")),
("/googleplus/oauth2callback", oauth_googleplus.CallbackHandler.to("/googleplus/add")),
("/googleplus/add", OAuthCallback),
("/googleplus/delete/start", oauth_googleplus.StartHandler.to("/googleplus/oauth2callback")),
],
debug=appengine_config.DEBUG,
)
开发者ID:uniteddiversity,项目名称:bridgy,代码行数:28,代码来源:googleplus.py
示例17: AddTumblr
self.response.out.write(template.render("templates/choose_blog.html", vars))
class AddTumblr(util.Handler):
def post(self):
auth_entity_key = util.get_required_param(self, "auth_entity_key")
self.maybe_add_or_delete_source(
Tumblr,
ndb.Key(urlsafe=auth_entity_key).get(),
util.get_required_param(self, "state"),
blog_name=util.get_required_param(self, "blog"),
)
class SuperfeedrNotifyHandler(superfeedr.NotifyHandler):
SOURCE_CLS = Tumblr
application = webapp2.WSGIApplication(
[
# Tumblr doesn't seem to use scope
# http://www.tumblr.com/docs/en/api/v2#oauth
("/tumblr/start", util.oauth_starter(oauth_tumblr.StartHandler).to("/tumblr/choose_blog")),
("/tumblr/choose_blog", ChooseBlog),
("/tumblr/add", AddTumblr),
("/tumblr/delete/finish", oauth_tumblr.CallbackHandler.to("/delete/finish")),
("/tumblr/notify/(.+)", SuperfeedrNotifyHandler),
],
debug=appengine_config.DEBUG,
)
开发者ID:snarfed,项目名称:bridgy,代码行数:30,代码来源:tumblr.py
示例18: super
is http://instagram.com
"""
return super(Instagram, self).canonicalize_syndication_url(
syndication_url, scheme='http')
class OAuthCallback(oauth_instagram.CallbackHandler, util.Handler):
"""OAuth callback handler.
The add, delete, and interactive publish flows have to share this because
Instagram only allows a single callback URL per app. :/
"""
def finish(self, auth_entity, state=None):
if 'target_url' in self.decode_state_parameter(state):
# this is an interactive publish
return self.redirect(util.add_query_params(
'/publish/instagram/finish',
util.trim_nulls({'auth_entity': auth_entity.key.urlsafe(), 'state': state})))
self.maybe_add_or_delete_source(Instagram, auth_entity, state)
application = webapp2.WSGIApplication([
('/instagram/start', util.oauth_starter(oauth_instagram.StartHandler).to(
'/instagram/oauth_callback')),
('/instagram/publish/start', oauth_instagram.StartHandler.to(
'/instagram/oauth_callback')),
('/instagram/oauth_callback', OAuthCallback),
], debug=appengine_config.DEBUG)
开发者ID:dev511,项目名称:bridgy,代码行数:30,代码来源:instagram.py
示例19: OAuthCallback
etag=self.last_activities_etag, fetch_replies=False, fetch_likes=False,
fetch_shares=False, count=50)
return []
class OAuthCallback(util.Handler):
"""OAuth callback handler.
Both the add and delete flows have to share this because Google+'s
oauth-dropin doesn't yet allow multiple callback handlers. :/
"""
def get(self):
auth_entity_str_key = util.get_required_param(self, 'auth_entity')
state = self.request.get('state')
if not state:
# state doesn't currently come through for G+. not sure why. doesn't
# matter for now since we don't plan to implement publish for G+.
state = self.construct_state_param_for_add(feature='listen')
auth_entity = ndb.Key(urlsafe=auth_entity_str_key).get()
self.maybe_add_or_delete_source(GooglePlusPage, auth_entity, state)
application = webapp2.WSGIApplication([
# OAuth scopes based on https://developers.google.com/+/api/oauth#scopes
('/googleplus/start', util.oauth_starter(oauth_googleplus.StartHandler).to(
'/googleplus/oauth2callback', scopes='https://www.googleapis.com/auth/plus.login')) ,
('/googleplus/oauth2callback', oauth_googleplus.CallbackHandler.to('/googleplus/add')),
('/googleplus/add', OAuthCallback),
('/googleplus/delete/start', oauth_googleplus.StartHandler.to('/googleplus/oauth2callback')),
], debug=appengine_config.DEBUG)
开发者ID:paulscallanjr,项目名称:bridgy,代码行数:30,代码来源:googleplus.py
示例20: SuperfeedrNotifyHandler
vars = {
'action': '/medium/add',
'state': state,
'auth_entity_key': auth_entity.key.urlsafe(),
'blogs': [{
'id': p['id'],
'title': p.get('name', ''),
'url': p.get('url', ''),
'pretty_url': util.pretty_link(str(p.get('url', ''))),
'image': p.get('imageUrl', ''),
} for p in pubs if p.get('id')],
}
logging.info('Rendering choose_blog.html with %s', vars)
self.response.headers['Content-Type'] = 'text/html'
self.response.out.write(JINJA_ENV.get_template('choose_blog.html').render(**vars))
class SuperfeedrNotifyHandler(superfeedr.NotifyHandler):
SOURCE_CLS = Medium
application = webapp2.WSGIApplication([
# https://github.com/Medium/medium-api-docs#user-content-21-browser-based-authentication
('/medium/start', util.oauth_starter(oauth_medium.StartHandler).to(
'/medium/choose_blog', scopes=('basicProfile', 'listPublications'))),
('/medium/add', AddMedium),
('/medium/choose_blog', ChooseBlog),
('/medium/delete/finish', oauth_medium.CallbackHandler.to('/delete/finish')),
('/medium/notify/(.+)', SuperfeedrNotifyHandler),
], debug=appengine_config.DEBUG)
开发者ID:snarfed,项目名称:bridgy,代码行数:30,代码来源:medium.py
注:本文中的util.oauth_starter函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论