Created
March 23, 2018 04:02
-
-
Save krypted/3bc28b55623b29d880d9996a58b0f035 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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