コード例 #1
0
    def goauth_request_client_credential(self, client_id, password=None):
        """
        This is designed to support section 4.4 of the OAuth 2.0 spec:

        "The client can request an access token using only its client
         credentials (or other supported means of authentication) when the
         client is requesting access to the protected resources under its
         control"
        """
        body = 'grant_type=client_credentials'
        path = '/goauth/token'
        method = 'POST'
        headers = sign_with_rsa(self.user_key_file,
                                path,
                                method,
                                client_id,
                                body=body,
                                password=password)
        url_parts = ('https', self.server, path, None, None)
        url = urlparse.urlunsplit(url_parts)
        response = requests.post(url,
                                 data={'grant_type': 'client_credentials'},
                                 headers=headers,
                                 verify=self.verify_ssl)
        return response.json()
コード例 #2
0
 def goauth_rsa_get_request_token(self, username, client_id, password=None):
     query_params = {"response_type": "code", "client_id": client_id}
     query_params = urllib.urlencode(query_params)
     path = '/goauth/authorize'
     method = 'GET'
     headers = sign_with_rsa(self.user_key_file,
                             path,
                             method,
                             username,
                             query=query_params,
                             password=password)
     url_parts = ('https', self.server, '/goauth/authorize', query_params,
                  None)
     url = urlparse.urlunsplit(url_parts)
     response = requests.get(url, headers=headers, verify=self.verify_ssl)
     return response.json()
コード例 #3
0
ファイル: client.py プロジェクト: kbase/auth_service
 def rsa_get_request_token(self, username, client_id, password=None):
     query_params = {
             "response_type": "code",
             "client_id": client_id
             }
     query_params = urllib.urlencode(query_params)
     path = '/goauth/authorize'
     method = 'GET'
     headers = sign_with_rsa(self.user_key_file,
             path,
             method,
             username,
             query=query_params,
             password=password)
     url_parts = ('https', self.server, '/goauth/authorize', query_params, None)
     url = urlparse.urlunsplit(url_parts)
     response = requests.get(url, headers=headers, verify=self.verify_ssl)
     return response.json
コード例 #4
0
ファイル: client.py プロジェクト: kbase/auth_service
    def request_client_credential(self, client_id, password=None):
        """
        This is designed to support section 4.4 of the OAuth 2.0 spec:

        "The client can request an access token using only its client
         credentials (or other supported means of authentication) when the
         client is requesting access to the protected resources under its
         control"
        """
        body = 'grant_type=client_credentials'
        path = '/goauth/token'
        method = 'POST'
        headers = sign_with_rsa(self.user_key_file,
                path,
                method,
                client_id,
                body=body,
                password=password)
        url_parts = ('https', self.server, path, None, None)
        url = urlparse.urlunsplit(url_parts)
        response = requests.post(url, data={'grant_type': 'client_credentials'}, headers=headers, verify=self.verify_ssl)
        return response.json