【问题标题】:AuthSub. How to check token existence? Python gdata clientAuthSub。如何检查令牌是否存在? Python gdata 客户端
【发布时间】:2012-08-27 23:03:49
【问题描述】:

我开发了一个装饰器来验证我的应用并开始使用 youtube API。指定装饰器来包装一个 REST 资源类方法。

def youtube_auth(f):                                            
    def wrap(self, *args, **kwargs):                            
        youtube_serv = gdata.youtube.service.YouTubeService()   
        youtube_serv.ssl = True                                 
        youtube_serv.developer_key = YOUTUBE_DEVELOPER_KEY      
        youtube_serv.client_id = YOUTUBE_CLIENT_ID              
        def get_auth_sub_url():                                 
            # TODO: do not forget to change it to real URL      
            next = 'http://www.example.com/video_upload'        
            scope = 'http://gdata.youtube.com'                  
            secure = False                                      
            session = True                                      

            return youtube_serv.GenerateAuthSubURL(next, scope, 
                 secure, session)                            

        # TODO: understand how to check authsub token           
        # if not youtube_serv.is_authenicated():                
        #     return redirect(get_auth_sub_url())               
        # else:                                                 
        #     parameters = cgi.FieldStorage()                   
        #     authsub_token = parameters.get('token')           
        #     yt_service = gdata.youtube.service.YouTubeService(
        #     yt_service.SetAuthSubToken(authsub_token)         
        #     yt_service.UpgradeToSessionToken()                

        return f(self, *args, **kwargs)                         
    return wrap                                                 

如何检查用户是否经过身份验证(令牌是否存在)?

【问题讨论】:

    标签: python youtube gdata authsub


    【解决方案1】:

    由于这是一款新应用,您应该考虑使用新的 OAuth 2.0 界面。此处的文档:https://developers.google.com/youtube/2.0/developers_guide_protocol_oauth2

    工作示例(php)在这里:Youtube Oauth 2.0 API Videos Upload Failed

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-30
      • 2011-09-20
      • 2015-01-27
      • 2013-01-16
      • 2015-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多