コード例 #1
0
 def do_verify(self, line):
     """
       verify [code]
       This will fetch an access code after you authenticated on geekli.st.
       You need to provide the verifier code shown on their website
     """
     self.result = self.oauth_api.access_token(self.result, line)
     access_token = self.result
     json_file = open(self.access_token_file_name, mode='w')
     json.dump(access_token, json_file)
     json_file.close()
     self.api = GeekListUserApi(consumer_info=consumer_info,
                                token=access_token)
コード例 #2
0
        try:
            return cmd.Cmd.onecmd(self, s)
        except GeeklistProblem as problem:
            print problem.response

    def preloop(self):
        """
            Make sure we have access to geekli.st.
            If not this will call authenticate for us.
        """
        if not self.api:
            return self.do_authenticate('')
        return cmd.Cmd.preloop(self)


if __name__ == '__main__':
    authorize_url = 'http://geekli.st/oauth/authorize'
    access_token_file_name = 'access.token.json'
    try:
        access_token_file = open(access_token_file_name, mode='r')
        access_token = json.load(access_token_file)
        api = GeekListUserApi(consumer_info=consumer_info, token=access_token)
    except:
        api = None

    cli = GeekCli()
    cli.api = api
    cli.access_token_file_name = access_token_file_name
    cli.authorize_url = authorize_url
    cli.cmdloop()