Error 400 sharefille api python3 with SSO login

83 Views Asked by At

I have a small snippet from api.sharefile.com

def authenticate(hostname, username, password): 
    uri_path = '/oauth/token'
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
    params = {
        'grant_type': 'password',
        'client_id': 'xxx',
        'client_secret': 'xxx',
        'username': username,
        'password': password
    }

    http = httplib.HTTPSConnection(hostname)
    http.request('POST', uri_path, urllib.urlencode(params), headers=headers)
    response = http.getresponse()

    print(response.status, response.reason)
    token = None
    if response.status == 200:
        token = json.loads(response.read())
        http.close()
    else:
        print(response.status)
    print(token)

authenticate('example.sharefile.com', '[email protected]', '123456')

This works fine when using a standard sharefile login but fails when using SSO authenticated users. Please advise how to resolve.

Thanks

0

There are 0 best solutions below