SoftLayer API OpenIdConnect Reset Password

2019-09-12 04:15发布

Hello: Using the SoftLayer API REST, I have a method that works fine when initiating a password reset. (email is sent to end user) However, when I encounter a newer user setup that uses the new OpenIdConnect, I receive an error: {u'code': u'SoftLayer_Exception_Public', u'error': u'This user is authenticated by OpenIdConnect and must use the OpenIdConnect provider to change their password.'}

So, I added a check on the return status and any error so that when the message OpenIdConnect is encountered I re-try using the new method SoftLayer_User_Customer_OpenIdConnect/initiatePortalPasswordChange. This however is not working. It returns a 500 with the same error message.

A simple example of my method is:

def set_user_password(self):
    ''' This method initiates a portal password reset process.'''


    myUser = {
       "parameters" : [self.username]
    }


    restreq = self._url('SoftLayer_User_Customer/initiatePortalPasswordChange.json')
    #print(restreq+"""',"""+' json=hwlist')
    r = requests.post(restreq, json=myUser)
    #pp(r)
    #pp(r.json())
    result = r.json()
    if 'SoftLayer_Exception_Public' in result['code']:
        print("Exception found - checking error")
    else:
        print("Unknown error.")
        return()
    if 'OpenIdConnect' in result['error']:
        print("OpenIdConnect error - this user is part of the new OpenID")
        newrestreq = self._url('SoftLayer_User_Customer_OpenIdConnect/initiatePortalPasswordChange.json')
        newr = requests.post(newrestreq, json=myUser)
        pp(newr)
        pp(newr.json())

The method above sends the second POST request but errors back with the same error, as if this SoftLayer method isn't supported. Below, I am running it:

Exception found - checking error OpenIdConnect error - this user is part of the new OpenID {u'code': u'SoftLayer_Exception_Public', u'error': u'This user is authenticated by OpenIdConnect and must use the OpenIdConnect provider to change their password.'} None

1条回答
别忘想泡老子
2楼-- · 2019-09-12 04:54

The issue is because your user created is a blueId user, so it means that you will not be able to change your password using SoftLayer's API. You need to change the password or reset the password using a bluemix api.

Also through UI: https://myibm.ibm.com/dashboard/ (after logging into IBMid)

查看更多
登录 后发表回答