Util package to drive Salesforce Oauth Web flow for scripting and testing.
Switch branches/tags
Clone or download
Pull request Compare This branch is 16 commits ahead of heroku:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
salesforce_oauth_request
tests
.gitignore
.travis.yml
HISTORY.rst
LICENSE
MANIFEST.in
README.rst
requirements.txt
setup.py
tox.ini

README.rst

Salesforce Oauth Request


NO LONGER USED

This library is no longer used or maintained by YPlan.


A bit of Requests driven utility code to drive the Salesforce.com Oauth2 Web flow. Use this module to login to a Salesforce account using just the username and password. Good for tests and scripts which need Salesforce access_token access.

Installation

pip install salesforce-oauth-request-yplan

Usage

You need a Connected App defined in Salesforce so that you have all these pieces of info:

  1. client ID
  2. client secret
  3. redirect uri

Now you can get an access_token and instance_url like this:

import salesforce_oauth_request

result = salesforce_oauth_request.login(username=username,
                                        password=password,
                                        client_id=client_id,
                                        client_secret=client_secret,
                                        redirect_uri=redirect_uri)

print "Access token:  {}".format(result['access_token'])
print "Refresh token: {}".format(result['refresh_token'])
print "Instance URL:  {}".format(result['instance_url'])

# Now use access_token, instance_url for REST, SOAP, or BULK API access.

Options

cache_session=True/False - default False

Pass the option cache_session=true to save the access token to ~.sf_oauth to save time on repeated runs.

sandbox=True/False - default False

Pass sandbox=True to use a sandbox login. ## Testing