Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional backend API calls after user authorization #102

Closed
maxtepkeev opened this issue Nov 22, 2013 · 3 comments
Closed

Additional backend API calls after user authorization #102

maxtepkeev opened this issue Nov 22, 2013 · 3 comments

Comments

@maxtepkeev
Copy link
Contributor

Hi,

Some backends, for example vk or odnoklassniki provide a function (vk_api and odnoklassniki_api) to make additional API calls. In python-social-auth compared to django-social-auth this function now accepts additional backend param, which should be the backend object.

What is the recommended way of getting this object outside the pipeline so that I could pass it to the function to make additional API calls. Should I just import a class and instantiate it or this object is already stored somewhere inside the user object ?

Thx

@omab
Copy link
Owner

omab commented Nov 22, 2013

Try with this:

from social.strategies.utils import get_current_strategy

# given a user instance (could be from request.user)
social = user.social_auth.get(provider='vk')
strategy = get_current_strategy()
backend = social.get_backend(strategy)

@maxtepkeev
Copy link
Contributor Author

Thanks, but social.get_backend(strategy) returns a class, and I needed an instance of that class, so I did social.get_backend(strategy)(strategy=strategy) and got back an instance, and now everything works perfectly.

Maybe it is a good idea to create a wrapper for the code above somewhere to ease access to backend instance object, thanks and feel free to close this issue.

@maxtepkeev
Copy link
Contributor Author

Helper to get backend instance was introduced in #114 (reference) and it workes perfectly. Closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants