question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using custom request

See original GitHub issue

Hi, Is there a way to access the request session that makes the call to salesforce in a view?

I am trying to use this package with OpenId credentials. Ultimately would like to do something like this:

def my_accounts(request):
    session = requests.Session()
    session.headers.update(...)
    Account.objects(session=session).all()

Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hynekcercommented, Apr 19, 2019

This is exactly what “dynamic authentication” does:

connections['salesforce'].sf_session.auth.dynamic_start(access_token, instance_url=instance_url)
# some work...
connections['salesforce'].sf_session.auth.dynamic_end()
# forgot the access token and optionally use the auth values that were valid before .dynamic_start(...)

It is regularly tested by tests/test_dynamic_auth/tests.py.

It should be thread safe to use different tokens/organizations in different in individual threads. That was tested manually four years ago, but no automated test exists.


Three years ago I wrote also a modified general SalesforceAuth that can work with a custom authentication class configurable by DATABASES settings, not on only the default SalesforcePasswordAuth or a direct work with tokens by auth.dynamic_start(), e.g. a class for interactive authentication by “Force.com CLI” by web browser, useful for development with Salesforce, without saving a password anywhere. It is not a part of production repository still and it is little obsoleted because SFDX is probably a better option now. If that solution would be committed then the dynamic auth probably will have to be enabled in settings to work.

0reactions
Blekelycommented, Apr 22, 2019

Thanks @philchristensen and @hynekcer, that does trick.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use custom request (make:request)? (laravel) Method ...
In ProfileRequest change extends FormRequest to extends Request . Then add use Illuminate\Http\Request; above the class.
Read more >
Validation - Laravel - The PHP Framework For Web Artisans
By reading this high-level overview, you'll be able to gain a good general understanding of how to validate incoming request data using Laravel: ......
Read more >
How to Create Custom Form Request Validations in Laravel ...
This tutorial describes how to create and use custom Form Request validation in your Laravel (5.8 or 6+) projects.
Read more >
Create a Custom Request | API Connector - Mixed Analytics
In this article, we'll walk through how to create a custom request using the API Connector add-on for Google Sheets. If you'd prefer...
Read more >
Custom Request and APIRoute class - FastAPI
Let's see how to make use of a custom Request subclass to decompress gzip requests. And an APIRoute subclass to use that custom...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found