コード例 #1
0
    def getAccessToken(self, code):
        response = urlutils.post("https://accounts.google.com/o/oauth2/token",
                                 data={
                                     "code": code,
                                     "client_id": self.client_id,
                                     "client_secret": self.client_secret,
                                     "redirect_uri": self.redirect_uri,
                                     "grant_type": "authorization_code"
                                 },
                                 headers={"Accept": "application/json"},
                                 verify=False)

        if response.status_code != 200:
            return None

        data = response.json()

        if data is None:
            return None
        elif "error" in data:
            raise auth.Failure(data["error"])
        elif "access_token" not in data:
            return None

        return data["access_token"]
コード例 #2
0
ファイル: github.py プロジェクト: runt18/critic
    def getAccessToken(self, code):
        response = urlutils.post(
            "https://github.com/login/oauth/access_token",
            data={"client_id": self.client_id, "client_secret": self.client_secret, "code": code},
            headers={"Accept": "application/json"},
        )

        if response.status_code != 200:
            return None

        data = response.json()

        if data is None:
            return None
        elif "error" in data:
            raise auth.Failure(data["error"])
        elif "access_token" not in data:
            return None

        return data["access_token"]
コード例 #3
0
    def getAccessToken(self, code):
        response = urlutils.post("https://github.com/login/oauth/access_token",
                                 data={
                                     "client_id": self.client_id,
                                     "client_secret": self.client_secret,
                                     "code": code
                                 },
                                 headers={"Accept": "application/json"})

        if response.status_code != 200:
            return None

        data = response.json()

        if data is None:
            return None
        elif "error" in data:
            raise auth.Failure(data["error"])
        elif "access_token" not in data:
            return None

        return data["access_token"]
コード例 #4
0
ファイル: google.py プロジェクト: Aessy/critic
    def getAccessToken(self, code):
        response = urlutils.post(
            "https://accounts.google.com/o/oauth2/token",
            data={ "code": code,
                   "client_id": self.client_id,
                   "client_secret": self.client_secret,
                   "redirect_uri": self.redirect_uri,
                   "grant_type": "authorization_code" },
            headers={ "Accept": "application/json" },
            verify=False)

        if response.status_code != 200:
            return None

        data = response.json()

        if data is None:
            return None
        elif "error" in data:
            raise auth.Failure(data["error"])
        elif "access_token" not in data:
            return None

        return data["access_token"]