在 SoftLayer 中模拟另一个用户
Impersonating another user in SoftLayer
我们在 SoftLayer 中有一个代理帐户,通过它创建了多个客户帐户。我正在尝试对客户帐户执行一些操作,但 API 不允许执行任何操作,因为我的 SoftLayer Python 客户端使用代理帐户的 username/password。
我浏览了很多帖子并模仿客户帐户的 "SoftLayer_User_Customer" 作为可能的解决方案,但没有太多关于如何使用它的细节。我能够使用 getImpersanationToken 调用获得令牌,但我不确定如何使用它。
是否有任何示例说明如何从主品牌帐户以客户用户身份登录(使用模拟或其他方式)?
我正在使用 Softlayer Python API 但也尝试过使用 SOAP 调用。
你需要的方法是这个:
http://sldn.softlayer.com/reference/services/SoftLayer_Brand/getToken
使用 python 客户端你会得到这样的东西:
token = client['SoftLayer_Brand'].getToken(userID, id=brandID)
其中 userID 是您要获取令牌的用户 ID,brandId 是您帐户的品牌 ID
您需要使用这样的 SOAP 请求:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.service.softlayer.com/soap/v3/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<ns1:clientLegacySession>
<userId>$USERID</userId>
<authToken>$TOKEN</authToken>
</ns1:clientLegacySession>
<ns1:SoftLayer_User_CustomerInitParameters>
<id>$USERID</id>
</ns1:SoftLayer_User_CustomerInitParameters>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:addApiAuthenticationKey/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
上面的 soap 正在为您在上一个请求中获得令牌的用户调用方法 http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer/addApiAuthenticationKey。
不要忘记替换 SOAP 中的值 $USERID 和 $TOKEN
此致
我们在 SoftLayer 中有一个代理帐户,通过它创建了多个客户帐户。我正在尝试对客户帐户执行一些操作,但 API 不允许执行任何操作,因为我的 SoftLayer Python 客户端使用代理帐户的 username/password。
我浏览了很多帖子并模仿客户帐户的 "SoftLayer_User_Customer" 作为可能的解决方案,但没有太多关于如何使用它的细节。我能够使用 getImpersanationToken 调用获得令牌,但我不确定如何使用它。
是否有任何示例说明如何从主品牌帐户以客户用户身份登录(使用模拟或其他方式)?
我正在使用 Softlayer Python API 但也尝试过使用 SOAP 调用。
你需要的方法是这个:
http://sldn.softlayer.com/reference/services/SoftLayer_Brand/getToken
使用 python 客户端你会得到这样的东西:
token = client['SoftLayer_Brand'].getToken(userID, id=brandID)
其中 userID 是您要获取令牌的用户 ID,brandId 是您帐户的品牌 ID
您需要使用这样的 SOAP 请求:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://api.service.softlayer.com/soap/v3/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header>
<ns1:clientLegacySession>
<userId>$USERID</userId>
<authToken>$TOKEN</authToken>
</ns1:clientLegacySession>
<ns1:SoftLayer_User_CustomerInitParameters>
<id>$USERID</id>
</ns1:SoftLayer_User_CustomerInitParameters>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:addApiAuthenticationKey/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
上面的 soap 正在为您在上一个请求中获得令牌的用户调用方法 http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer/addApiAuthenticationKey。
不要忘记替换 SOAP 中的值 $USERID 和 $TOKEN
此致