a_frame/utils/action_providers/RestAction.py
def __connect_to_oauth2(self):
        """
        connects to OAuth2 with the specified user and password

        :return: boolean if successful

        """

        _auth_json = """
            { "grant_type": "password",
              "username": "%s",
              "password": "%s"
            }
            """ % (self.username, self.password)

        full_url = self.protocol + "://" + self.host + self._oauth2_auth_path
        print(full_url)
        request = urllib2.Request(full_url)

        print("OAuth2 using username/password: %s %s" % (self.username, self.password))
        base64string = base64.b64encode("%s:%s" % (self.username, self.password))
        request.add_header("Authorization", "Basic %s" % base64string)
        request.add_header("Content-Type", "application/json")

        result = self.__perform_post(request, _auth_json).read()

        try:
            json_string = json.loads(result)
            print("Found OAuth2 JSON result")
        except ValueError:
            print("Unknown OAuth2 result!")
            return False

        if not json_string["token_type"] or not json_string["access_token"]:
            return False

        self._auth_token = json_string["token_type"] + " " + json_string["access_token"]
        return True

        connects to OAuth2 with the specified user and password

        :return: boolean if successful

        
connects to OAuth2 with the specified user and password
connects to OAuth2 with the specified user and password
def __connect_to_oauth2(self):
        _auth_json = """
            { "grant_type": "password",
              "username": "%s",
              "password": "%s"
            }
            """ % (self.username, self.password)
        full_url = self.protocol + "://" + self.host + self._oauth2_auth_path
        print(full_url)
        request = urllib2.Request(full_url)
        print("OAuth2 using username/password: %s %s" % (self.username, self.password))
        base64string = base64.b64encode("%s:%s" % (self.username, self.password))
        request.add_header("Authorization", "Basic %s" % base64string)
        request.add_header("Content-Type", "application/json")
        result = self.__perform_post(request, _auth_json).read()
        try:
            json_string = json.loads(result)
            print("Found OAuth2 JSON result")
        except ValueError:
            print("Unknown OAuth2 result!")
            return False
        if not json_string["token_type"] or not json_string["access_token"]:
            return False
        self._auth_token = json_string["token_type"] + " " + json_string["access_token"]
        return True
def __connect_to_oauth2 ( self ) : _auth_json = """
            { "grant_type": "password",
              "username": "%s",
              "password": "%s"
            }
            """ % ( self . username , self . password ) full_url = self . protocol + "://" + self . host + self . _oauth2_auth_path print ( full_url ) request = urllib2 . Request ( full_url ) print ( "OAuth2 using username/password: %s %s" % ( self . username , self . password ) ) base64string = base64 . b64encode ( "%s:%s" % ( self . username , self . password ) ) request . add_header ( "Authorization" , "Basic %s" % base64string ) request . add_header ( "Content-Type" , "application/json" ) result = self . __perform_post ( request , _auth_json ) . read ( ) try : json_string = json . loads ( result ) print ( "Found OAuth2 JSON result" ) except ValueError : print ( "Unknown OAuth2 result!" ) return False if not json_string [ "token_type" ] or not json_string [ "access_token" ] : return False self . _auth_token = json_string [ "token_type" ] + " " + json_string [ "access_token" ] return True
connects to OAuth2 with the specified user and password
connects to OAuth2 with the specified user and password
"""
        connects to OAuth2 with the specified user and password

        :return: boolean if successful

        """
boolean if successful
boolean if successful
self