Util package to drive Salesforce Oauth Web flow for testing.
Project description
# Salesforce Oauth Request
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```
## 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: %s" + result['access_token']
print "Refresh token: %s" + result['refresh_token']
print "Instance URL: %s" + 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
You can run the simple test script like this:
```python test.py```
It will prompt you for all the values, drive the login, and print the results.
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```
## 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: %s" + result['access_token']
print "Refresh token: %s" + result['refresh_token']
print "Instance URL: %s" + 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
You can run the simple test script like this:
```python test.py```
It will prompt you for all the values, drive the login, and print the results.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for salesforce-oauth-request-yplan-1.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e774fcb739c5c77d7733b780e4f613857b84a44359ad3db2e305ac2859f6dba |
|
MD5 | 493f36ec87e02762f2e4b91d4a2f6ee0 |
|
BLAKE2b-256 | 39f1393a09dccc4e34eb27ef7a9113a09d262a0e31fd8acd2fe641fa6ebe45f4 |