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

How to continue pipeline #122

Closed
jd-solanki opened this issue Apr 13, 2020 · 3 comments
Closed

How to continue pipeline #122

jd-solanki opened this issue Apr 13, 2020 · 3 comments

Comments

@jd-solanki
Copy link
Contributor

jd-solanki commented Apr 13, 2020

Hi, I have am using @partial to pause the pipeline but I don't know how to resume it.

I have checked your example project but I can't anything related to continuing pipeline.

To which URL I should make request. Is it post/get method.

Actually, I have tried various ways before creating this issue like adding social_django urls and making post request to complete view but I am unable to set received data from user e.g. email.

@api_view(["GET","POST"])
@permission_classes([AllowAny,])
def require_email(request):
    strategy = load_strategy()
    partial_token = request.GET.get('partial_token')
    partial = strategy.partial_load(partial_token)

    if request.method == 'POST':
        request.session['email'] = request.data.get('email')

        redirect_url = reverse('social:complete', kwargs={'backend': partial.backend}) + "?partial_token=" + partial_token

        return redirect(redirect_url)
    else:
        return Response({'error': "Email wasn't provided by oauth provider", 'continue_url': f"{reverse('require_email')}?partial_token={partial_token}", 'token': partial_token}, status=202)
@partial
def check_email(strategy, backend, request, response, is_new, details, user=None, *args, **kwargs):

    if user and user.email:
        return

    elif is_new and not details.get('email'):
        email = strategy.session_get('email')

        if email:
            details['email'] = email
        else:
            current_partial = kwargs.get('current_partial')

            return strategy.redirect(f"{reverse('require_email')}?partial_token={kwargs.get('current_partial').token}")

So, @st4lk can you please help me out.

~ Regards

@st4lk
Copy link
Owner

st4lk commented Apr 19, 2020

Hi @jd-0001

Current package doesn't provide means for resuming paused pipeline.

There is an attempt to do it: #105. I haven't checked it fully yet, will try to do it soon.

BTW, PRs are warmly welcome!

@jd-solanki
Copy link
Contributor Author

jd-solanki commented Apr 22, 2020

Hi, @st4lk Have you tried. After the digging of 3 days in every used package till social-core somehow I managed to resume the pipeline but still, I am not able to complete the flow.

After completion of the pipeline I get redirected to account/profiles(account is my app url prefix) then I updated SOCIAL_AUTH_LOGIN_REDIRECT_URL but in that view I if I access request.user it is still anonymous.
I don't know if a user is logged in yet or not. How to get both user and token so I can send back response to my front-end with user and token?

Any Idea?

I hope you are safe during this days 🏠

~ Regards

@jd-solanki
Copy link
Contributor Author

jd-solanki commented Aug 12, 2020

I have fixed this. There was some config related to:

SOCIAL_AUTH_FORCE_EMAIL_VALIDATION
SOCIAL_AUTH_EMAIL_VALIDATION_URL
SOCIAL_AUTH_LOGIN_REDIRECT_URL
SOCIAL_AUTH_EMAIL_VALIDATION_FUNCTION

after configuring them, I was to continue pipeline

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