Esempio n. 1
0
    def get_user_info(self, token):
        """Get qq user info

        :type token: str
        :param token:

        :rtype: dict
        :return:
            "url":"https://api.github.com/users/juniwang","html_url":"https://github.com/juniwang",
            "followers_url":"https://api.github.com/users/juniwang/followers",        log.debug("get admin user info from " + provider + " : "  + user_info_resp + '\n' )

            "following_url":"https://api.github.com/users/juniwang/following{/other_user}",
            "starred_url":"https://api.github.com/users/juniwang/starred{/owner}{/repo}",
            "gists_url":"https://api.github.com/users/juniwang/gists{/gist_id}",
            "events_url":"https://api.github.com/users/juniwang/events{/privacy}",
            {"login":"******","id":8814383,"avatar_url":"https://avatars.githubusercontent.com/u/8814383?v=3","gravatar_id":"",
            "subscriptions_url":"https://api.github.com/users/juniwang/subscriptions",
            "received_events_url":"https://api.github.com/users/juniwang/received_events","type":"User","site_admin":false,
            "name":"Junbo Wang","company":"","blog":"","location":"Shanghai China",
            "organizations_url":"https://api.github.com/users/juniwang/orgs","repos_url":"https://api.github.com/users/juniwang/repos",

            "email":"*****@*****.**","hireable":false,"bio":null,"public_repos":12,"public_gists":0,"followers":0,
            "following":1,"created_at":"2014-09-18T01:30:30Z","updated_at":"2014-11-25T09:00:37Z","private_gists":0,
            "plan":{"name":"free","space":307200,"collaborators":0,"private_repos":0}}
            "total_private_repos":0,"owned_private_repos":0,"disk_usage":14179,"collaborators":0,

        """
        user_info_resp = get_remote(get_config('login.github.user_info_url') + token)

        user_info = json.loads(user_info_resp)
        if user_info.get("message") is not None:
            raise Exception(user_info)

        return user_info
Esempio n. 2
0
    def get_user_info(self, token, uid):
        """Get weibo user info

        :type token: str
        :param token:

        :type uid: str
        :param uid:

        :rtype: dict
        :return:
            {"id":2330622122,"idstr":"2330622122","class":1,"screen_name":"test name","name":"test name",
            "province":"31","city":"10","location":"shanghai yangpu","description":"","url":"",
            "profile_image_url":"http://tp3.sinaimg.cn/2330622122/50/5629035320/1",
            "profile_url":"u/2330622122","domain":"","weihao":"","gender":"m","followers_count":34,
            "friends_count":42,"pagefriends_count":0,"statuses_count":0,"favourites_count":1,
            "created_at":"Mon Aug 22 17:58:15 +0800 2011","following":false,"allow_all_act_msg":false,
            "geo_enabled":true,"verified":false,"verified_type":-1,"remark":"","ptype":0,"allow_all_comment":true,
            "avatar_large":"http://tp3.sinaimg.cn/2330622122/180/5629035320/1","avatar_hd":"http://tp3.sinaimg.cn/2330622122/180/5629035320/1",
            "verified_reason":"","verified_trade":"","verified_reason_url":"","verified_source":"","verified_source_url":"",
            "follow_me":false,"online_status":0,"bi_followers_count":8,"lang":"zh-cn","star":0,"mbtype":0,"mbrank":0,
            "block_word":0,"block_app":0,"credit_score":80,"urank":6}
        """

        # https://api.weibo.com/2/users/show.json?access_token=2.005RDjXC0rYD8d39ca83156aLZWgZE&uid=1404376560
        user_info_resp = get_remote(get_config('login.weibo.user_info_url') + token + "&uid=" + uid)

        user_info = json.loads(user_info_resp)

        if user_info.get("error") is not None:
            raise Exception(user_info)

        return user_info
Esempio n. 3
0
    def get_user_info(self, token):
        """Get qq user info

        :type token: str
        :param token:

        :rtype: dict
        :return:
            "url":"https://api.github.com/users/juniwang","html_url":"https://github.com/juniwang",
            "followers_url":"https://api.github.com/users/juniwang/followers",        log.debug("get admin user info from " + provider + " : "  + user_info_resp + '\n' )

            "following_url":"https://api.github.com/users/juniwang/following{/other_user}",
            "starred_url":"https://api.github.com/users/juniwang/starred{/owner}{/repo}",
            "gists_url":"https://api.github.com/users/juniwang/gists{/gist_id}",
            "events_url":"https://api.github.com/users/juniwang/events{/privacy}",
            {"login":"******","id":8814383,"avatar_url":"https://avatars.githubusercontent.com/u/8814383?v=3","gravatar_id":"",
            "subscriptions_url":"https://api.github.com/users/juniwang/subscriptions",
            "received_events_url":"https://api.github.com/users/juniwang/received_events","type":"User","site_admin":false,
            "name":"Junbo Wang","company":"","blog":"","location":"Shanghai China",
            "organizations_url":"https://api.github.com/users/juniwang/orgs","repos_url":"https://api.github.com/users/juniwang/repos",

            "email":"*****@*****.**","hireable":false,"bio":null,"public_repos":12,"public_gists":0,"followers":0,
            "following":1,"created_at":"2014-09-18T01:30:30Z","updated_at":"2014-11-25T09:00:37Z","private_gists":0,
            "plan":{"name":"free","space":307200,"collaborators":0,"private_repos":0}}
            "total_private_repos":0,"owned_private_repos":0,"disk_usage":14179,"collaborators":0,

        """
        user_info_resp = get_remote(
            get_config('login.github.user_info_url') + token)

        user_info = json.loads(user_info_resp)
        if user_info.get("message") is not None:
            raise Exception(user_info)

        return user_info
Esempio n. 4
0
    def get_user_info(self, token, uid):
        """Get weibo user info

        :type token: str
        :param token:

        :type uid: str
        :param uid:

        :rtype: dict
        :return:
            {"id":2330622122,"idstr":"2330622122","class":1,"screen_name":"test name","name":"test name",
            "province":"31","city":"10","location":"shanghai yangpu","description":"","url":"",
            "profile_image_url":"http://tp3.sinaimg.cn/2330622122/50/5629035320/1",
            "profile_url":"u/2330622122","domain":"","weihao":"","gender":"m","followers_count":34,
            "friends_count":42,"pagefriends_count":0,"statuses_count":0,"favourites_count":1,
            "created_at":"Mon Aug 22 17:58:15 +0800 2011","following":false,"allow_all_act_msg":false,
            "geo_enabled":true,"verified":false,"verified_type":-1,"remark":"","ptype":0,"allow_all_comment":true,
            "avatar_large":"http://tp3.sinaimg.cn/2330622122/180/5629035320/1","avatar_hd":"http://tp3.sinaimg.cn/2330622122/180/5629035320/1",
            "verified_reason":"","verified_trade":"","verified_reason_url":"","verified_source":"","verified_source_url":"",
            "follow_me":false,"online_status":0,"bi_followers_count":8,"lang":"zh-cn","star":0,"mbtype":0,"mbrank":0,
            "block_word":0,"block_app":0,"credit_score":80,"urank":6}
        """

        # https://api.weibo.com/2/users/show.json?access_token=2.005RDjXC0rYD8d39ca83156aLZWgZE&uid=1404376560
        user_info_resp = get_remote(
            get_config('login.weibo.user_info_url') + token + "&uid=" + uid)

        user_info = json.loads(user_info_resp)

        if user_info.get("error") is not None:
            raise Exception(user_info)

        return user_info
Esempio n. 5
0
    def _access_wxapi_or_raise(self, *args, **kwargs):
        """access remote with under wechat'api's interface

        just a simple wrapper on `get_remote`
        raise error on response error
        """
        r = json.loads(get_remote(*args, **kwargs))

        if "errcode" in r:
            raise Exception("errcode: " + str(r["errcode"]) + ", errmsg: " + r["errmsg"])

        return r
Esempio n. 6
0
    def _access_wxapi_or_raise(self, *args, **kwargs):
        """access remote with under wechat'api's interface

        just a simple wrapper on `get_remote`
        raise error on response error
        """
        r = json.loads(get_remote(*args, **kwargs))

        if "errcode" in r:
            raise Exception("errcode: " + str(r["errcode"]) + ", errmsg: " + r["errmsg"])

        return r
Esempio n. 7
0
    def get_emails(self, token):
        """Get user primary email

        :type token: str
        :param token:

        :rtype: dict
        :return: emails
        """
        email_info_resp = get_remote(get_config('login.github.emails_info_url') + token)
        email_list = json.loads(email_info_resp)

        return email_list
Esempio n. 8
0
    def get_emails(self, token):
        """Get user primary email

        :type token: str
        :param token:

        :rtype: dict
        :return: emails
        """
        email_info_resp = get_remote(get_config('login.github.emails_info_url') + token)
        email_list = json.loads(email_info_resp)

        return email_list
Esempio n. 9
0
    def get_token(self, code):
        """ Get gitcafe access token

        :type code: str
        :param code:

        :rtype: str
        :return: access token
        """
        token_resp = get_remote(get_config("login.gitcafe.access_token_url") + code)
        query = qs_dict(token_resp)
        if query.get("error") is not None:
            raise Exception(query)

        return query["access_token"]
Esempio n. 10
0
    def get_token(self, code):
        """ Get gitcafe access token

        :type code: str
        :param code:

        :rtype: str
        :return: access token
        """
        token_resp = get_remote(
            get_config("login.gitcafe.access_token_url") + code)
        query = qs_dict(token_resp)
        if query.get("error") is not None:
            raise Exception(query)

        return query["access_token"]
Esempio n. 11
0
    def get_email(self, token, uid):
        """Get weibo user info

        :type token: str
        :param token:

        :rtype: str
        :return : email
        """

        email_info_resp = get_remote(get_config('login.weibo.email_info_url') + token)
        email_info_resp_json = json.loads(email_info_resp)

        if email_info_resp_json.get("error") is not None:
            raise Exception(email_info_resp_json)

        return email_info_resp_json['email']
Esempio n. 12
0
    def get_email(self, token, uid):
        """Get weibo user info

        :type token: str
        :param token:

        :rtype: str
        :return : email
        """

        email_info_resp = get_remote(get_config('login.weibo.email_info_url') + token)
        email_info_resp_json = json.loads(email_info_resp)

        if email_info_resp_json.get("error") is not None:
            raise Exception(email_info_resp_json)

        return email_info_resp_json['email']
Esempio n. 13
0
    def get_token(self, code):
        """ Get qq access token

        :type code: str
        :param code:

        :rtype: str
        :return: access token
        """

        state = "openhackathon"
        token_resp = get_remote(get_config("login.qq.access_token_url") + code + "&state=" + state)
        if token_resp.find('callback') == 0:
            error = json.loads(token_resp[10:-4])
            raise Exception(error)

        query = qs_dict(token_resp)
        return query["access_token"]
Esempio n. 14
0
    def get_info(self, token):
        """ Get qq open id

        :type token: str
        :param token:

        :rtype: dict
        :return: info
        """

        openid_resp = get_remote(get_config("login.qq.openid_url") + token)
        log.debug("get access_token from qq:" + token)
        info = json.loads(openid_resp[10:-4])

        if info.get("error") is not None:
            raise Exception(info)

        return info
Esempio n. 15
0
    def get_token(self, code):
        """ Get qq access token

        :type code: str
        :param code:

        :rtype: str
        :return: access token
        """

        state = "openhackathon"
        token_resp = get_remote(get_config("login.qq.access_token_url") + code + "&state=" + state)
        if token_resp.find('callback') == 0:
            error = json.loads(token_resp[10:-4])
            raise Exception(error)

        query = qs_dict(token_resp)
        return query["access_token"]
Esempio n. 16
0
    def get_info(self, token):
        """ Get qq open id

        :type token: str
        :param token:

        :rtype: dict
        :return: info
        """

        openid_resp = get_remote(get_config("login.qq.openid_url") + token)
        log.debug("get access_token from qq:" + token)
        info = json.loads(openid_resp[10:-4])

        if info.get("error") is not None:
            raise Exception(info)

        return info
Esempio n. 17
0
    def get_user_info(self, token):
        """Get live user info

        :type token: str
        :param token:

        :rtype: dict
        :return:
            {'first_name': 'Ice', 'last_name': 'Shi', 'name': 'Ice Shi', 'locale': 'en_US',
            'gender': None,
            'emails': {'personal': None, 'account': '*****@*****.**', 'business': None, 'preferred': '*****@*****.**'},
            'link': 'https://profile.live.com/',
            'updated_time': '2015-05-13T02:28:32+0000',
            'id': '655c03b1b314b5ee'}
        """

        user_info_resp = get_remote(get_config('login.live.user_info_url') + token)
        user_info = json.loads(user_info_resp)

        if user_info.get("error") is not None:
            raise Exception(user_info)

        return user_info
Esempio n. 18
0
    def get_user_info(self, token):
        """Get live user info

        :type token: str
        :param token:

        :rtype: dict
        :return:
            {'first_name': 'Ice', 'last_name': 'Shi', 'name': 'Ice Shi', 'locale': 'en_US',
            'gender': None,
            'emails': {'personal': None, 'account': '*****@*****.**', 'business': None, 'preferred': '*****@*****.**'},
            'link': 'https://profile.live.com/',
            'updated_time': '2015-05-13T02:28:32+0000',
            'id': '655c03b1b314b5ee'}
        """

        user_info_resp = get_remote(get_config('login.live.user_info_url') + token)
        user_info = json.loads(user_info_resp)

        if user_info.get("error") is not None:
            raise Exception(user_info)

        return user_info
Esempio n. 19
0
    def get_user_info(self, token, openid, client_id):
        """Get qq user info

        :type token: str
        :param token:

        :type openid: str
        :param openid:

        :type client_id: str
        :param client_id:

        :rtype: dict
        :return: user info
        """

        url = get_config("login.qq.user_info_url") % (token, client_id, openid)
        user_info_resp = get_remote(url)
        user_info = convert(json.loads(user_info_resp))

        if user_info.get("ret") != 0:
            raise Exception(user_info)

        return user_info
Esempio n. 20
0
    def get_user_info(self, token, openid, client_id):
        """Get qq user info

        :type token: str
        :param token:

        :type openid: str
        :param openid:

        :type client_id: str
        :param client_id:

        :rtype: dict
        :return: user info
        """

        url = get_config("login.qq.user_info_url") % (token, client_id, openid)
        user_info_resp = get_remote(url)
        user_info = convert(json.loads(user_info_resp))

        if user_info.get("ret") != 0:
            raise Exception(user_info)

        return user_info