heroku / salesforce-oauth-request Goto Github PK
View Code? Open in Web Editor NEWUtil package to drive Salesforce Oauth Web flow for scripting and testing.
License: MIT License
Util package to drive Salesforce Oauth Web flow for scripting and testing.
License: MIT License
The test even fails.
I get:
AssertionError: Couldn't find location.href expression in page https://cs15.salesforce.com/secur/frontdoor.jsp?sid=FOOOOOOOBAR (Username or password is wrong)
Clearly the username and password are correct as I am getting a frontdoor URL and my user login history shows a successful login. The library is just not properly parsing out sessions and tokens.
Hi Scott,
Thank you for creating this module. It was very helpful to me.
I have found two issues with it that I fixed locally in my download and would like to have them incorporated into main library.
Below is modifications I made to the code that could be incorporated into code to fix these issues:
if not os.environ.has_key('HOME'):
os.environ['HOME'] = os.path.join(os.environ['HOMEDRIVE'], \
os.environ['HOMEPATH'])
inside website_login procedure I added a check for sandbox parameter and redirect to test.salesforce.com if it is true:
def website_login(username = None, password = None, client_id = None, client_secret = None,
redirect_uri = None, sandbox = None, cache_session = None,
state = None):
base = "https://login.salesforce.com" if not sandbox else "https://test.salesforce.com"
auth_url = base + "/services/oauth2/authorize?"
client_id = os.environ.get('SALESFORCE_CLIENT_ID', client_id)
client_secret = os.environ.get('SALESFORCE_CLIENT_SECRET', client_secret)
redirect_uri = os.environ.get('SALESFORCE_REDIRECT_URI', redirect_uri)
auth_url += urllib.urlencode([
("response_type", "code"),
("display", "popup"),
("client_id",client_id),
("redirect_uri", redirect_uri),
("prompt", "login"),
("state", state)])
s = requests.session()
redirect_return = oauth_flow(s, auth_url, username=username, password=password)
# parse out the session id and endpoint
params = urlparse.parse_qs(redirect_return)
data = dict(code=params['code'],
grant_type="authorization_code",
client_id=client_id,
client_secret=client_secret,
redirect_uri=redirect_uri,
format="json")
code_url = base + "/services/oauth2/token"
return requests.post(code_url, data=data)
I get " ImportError: No module named 'urlparse' " .
Did I install it wrong (pip install ...) or is it python2.7 only code?
Thanks,
-jon
Is there another project taking over for this? No changes have been merged for a year.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.