Skip to content

Instantly share code, notes, and snippets.

@krypted
Created March 23, 2018 04:02
Show Gist options
  • Save krypted/3bc28b55623b29d880d9996a58b0f035 to your computer and use it in GitHub Desktop.
Save krypted/3bc28b55623b29d880d9996a58b0f035 to your computer and use it in GitHub Desktop.
import requests
import json
import sys
print("Script Starting...")
print("")
access_token_url = 'https://login.salesforce.com/services/oauth2/token'
data = {
'grant_type': 'password',
'client_id': 'INSERTYOURCLIENTIDHERE',
'client_secret': 'INSERTYOURSECRETHERE',
'username': sys.argv[1],
'password': sys.argv[2]
}
headers = {
'content-type': 'application/x-www-form-urlencoded'
}
req = requests.post(access_token_url, data=data, headers=headers)
response = req.json()
print("Completed Response ==> ")
print(json.dumps(response, indent=4,))
print("")
print("Access Token ==> " + response['access_token'])
print("")
print("Script Completed...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment