Git Product home page Git Product logo

salesforce-oauth-request's Issues

Could't find location.href expression

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.

Project does not work on windows. Library does not work with test salesforce environment

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.

  1. this library does not work on windows, because there is no notion of HOME variable.
  2. Library does not work properly with test environment of salesforce when sandbox flag is set to true.

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)

Is this project dead?

Is there another project taking over for this? No changes have been merged for a year.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.