Ejemplo n.º 1
0
    def authorize(self):
        result = True

        if (not self.setup()):
            return False

        if (self.isAuthorized()):
            # delete the token to start over
            self._deleteToken()

        # copied flow from http://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.oauth.DropboxOAuth2FlowNoRedirect
        flow = dropbox.oauth.DropboxOAuth2FlowNoRedirect(
            self.APP_KEY, self.APP_SECRET)

        url = flow.start()

        # print url in log
        utils.log("Authorize URL: " + url)
        xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30056),
                            utils.getString(30057), tinyurl.shorten(url))

        # get the auth code
        code = xbmcgui.Dialog().input(
            utils.getString(30027) + ' ' + utils.getString(30103))

        # if user authorized this will work

        try:
            user_token = flow.finish(code)
            self._setToken(user_token.access_token)
        except Exception as e:
            utils.log("Error: %s" % (e, ))
            result = False

        return result
Ejemplo n.º 2
0
    def authorize(self):
        result = True

        if (not self.setup()):
            return False

        #create authorization helper and load default settings
        gauth = GoogleAuth(
            xbmc.validatePath(
                xbmc.translatePath(utils.addon_dir() +
                                   '/resources/lib/pydrive/settings.yaml')))
        gauth.LoadClientConfigSettings()

        settings = {
            "client_id": self.CLIENT_ID,
            'client_secret': self.CLIENT_SECRET
        }

        drive_url = gauth.GetAuthUrl(settings)

        utils.log("Google Drive Authorize URL: " + drive_url)

        xbmcgui.Dialog().ok(utils.getString(30010), utils.getString(30056),
                            utils.getString(30102), tinyurl.shorten(drive_url))
        code = xbmcgui.Dialog().input(
            utils.getString(30098) + ' ' + utils.getString(30103))

        gauth.Auth(code)
        gauth.SaveCredentialsFile(
            xbmc.validatePath(
                xbmc.translatePath(utils.data_dir() + 'google_drive.dat')))

        return result
Ejemplo n.º 3
0
    def authorize(self):
        result = True

        if(not self.setup()):
            return False
        
        if(self.isAuthorized()):
            #delete the token to start over
            self._deleteToken()

        #copied flow from http://dropbox-sdk-python.readthedocs.io/en/latest/moduledoc.html#dropbox.oauth.DropboxOAuth2FlowNoRedirect
        flow = dropbox.oauth.DropboxOAuth2FlowNoRedirect(self.APP_KEY,self.APP_SECRET)

        url = flow.start()

        #print url in log
        utils.log("Authorize URL: " + url)
        xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30056),utils.getString(30057),tinyurl.shorten(url))

        #get the auth code
        code = xbmcgui.Dialog().input(utils.getString(30027) + ' ' + utils.getString(30103))
        
        #if user authorized this will work

        try:
            user_token = flow.finish(code)
            self._setToken(user_token.access_token)
        except Exception,e:
            utils.log("Error: %s" % (e,))
            result = False
Ejemplo n.º 4
0
    def authorize(self):
        result = True

        if(not self.setup()):
            return False

        #create authorization helper and load default settings
        gauth = GoogleAuth(xbmc.validatePath(xbmc.translatePath(utils.addon_dir() + '/resources/lib/pydrive/settings.yaml')))
        gauth.LoadClientConfigSettings()

        settings = {"client_id":self.CLIENT_ID,'client_secret':self.CLIENT_SECRET}
    
        drive_url = gauth.GetAuthUrl(settings)
    
        utils.log("Google Drive Authorize URL: " + drive_url)

        xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30056),utils.getString(30102),tinyurl.shorten(drive_url))
        code = xbmcgui.Dialog().input(utils.getString(30098) + ' ' + utils.getString(30103))

        gauth.Auth(code)
        gauth.SaveCredentialsFile(xbmc.validatePath(xbmc.translatePath(utils.data_dir() + 'google_drive.dat')))

        return result