Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BearerAuthentication Should throw an error if the user has the XMLRPC endpoint enabled #1939

Open
allmightyspiff opened this issue May 10, 2023 · 1 comment
Assignees
Labels

Comments

@allmightyspiff
Copy link
Member

BearerAuthentication

IAMClient might also want to throw an exception for that too.

I'd rather not set the URL specifically incase someone is using a non-standard api endpoint or something

@allmightyspiff allmightyspiff self-assigned this May 10, 2023
@allmightyspiff
Copy link
Member Author

allmightyspiff commented May 10, 2023

Also, add docs on how to use IAMClient

rough example

import requests
import SoftLayer

hdrs = { 'Accept'       : 'application/json',
         'Content-Type' : 'application/x-www-form-urlencoded' }
params = { 'grant_type' : 'urn:ibm:params:oauth:grant-type:apikey',
           'apikey'     : '32characterLongAPIKEYhere' }
resp = requests.post('https://iam.cloud.ibm.com/identity/token', data = params, headers = hdrs)
assert resp.status_code in (200, 202)
json = resp.json()

auth  = SoftLayer.auth.BearerAuthentication('', json['access_token'])
client = SoftLayer.API.IAMClient(auth = auth)
debugger = SoftLayer.DebugTransport(client.transport)
client.transport = debugger

try:
    result = client['SoftLayer_Account'].getObject()
    print(result['id'])
    print("======== RESULT ========")
except Exception as e:
    print(e)

for call in client.transport.get_last_calls():
    print(client.transport.print_reproduceable(call))


"""
$> python test.py
Calling: SoftLayer_Account::getObject(id=None, mask='', filter='None', args=(), limit=None, offset=None))
307608
======== RESULT ========
curl -u $SL_USER:$SL_APIKEY -X GET -H "Accept: */*" -H "Accept-Encoding: gzip, deflate, compress" 
-H "Authorization: Bearer aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaTHIS IS THE WHERE THE TOKEN WOULD BE....aaaaaaaaaaaaaaaaaaaa"
'https://api.softlayer.com/rest/v3.1/SoftLayer_Account/getObject.json'
""""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant