Skip to content

Instantly share code, notes, and snippets.

@chrisjsimpson
Created March 25, 2019 20:04
Show Gist options
  • Save chrisjsimpson/7ba6b7a58104ca3b49dd9d4990788dce to your computer and use it in GitHub Desktop.
Save chrisjsimpson/7ba6b7a58104ca3b49dd9d4990788dce to your computer and use it in GitHub Desktop.

Revisions

  1. chrisjsimpson created this gist Mar 25, 2019.
    23 changes: 23 additions & 0 deletions get-direct-login.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    '''
    You need to install pythin requests library for this to work
    e.g. pip install requests
    You also need to use python3
    '''

    import requests
    consumer_key = input("Consumer Key --> ")
    username = input("Username --> ")
    password = input("Password --> ")
    url = input("Endpoint URL --> ")

    authorization = 'DirectLogin username="{}", password="{}", consumer_key="{}"'.format(username, password, consumer_key)

    headers={
    'Accept': 'application/json',
    'Authorization': authorization
    }

    req = requests.post(url, headers=headers)

    print("Your access token is:")
    print(req.text)