Interaction between PSA and mibile app

83 views
Skip to first unread message

Karmadon

unread,
Jan 4, 2014, 5:53:50 AM1/4/14
to django-so...@googlegroups.com
Hello!

I used DSA to authenticate my mobile app in django. But few days ago I decided to use PSA.

Everything worked good with DSA but when I try to use PSA I get this error: http://dpaste.com/hold/1536153/

And here is my code:

from django.conf import settings
from social.backends.utils import get_backend
from social.apps.django_app.utils import load_strategy

@csrf_exempt
@never_cache
def mobile_auth(request, *args, **kwargs ):

    user= None
    backend = 'vk-oauth2' # 'facebook'

    access_token = request.GET.get('access_token') or request.POST.get('access_token')
    user_id = request.GET.get('user_id') or request.POST.get('user_id')

    social_auth_backend = get_backend(settings.AUTHENTICATION_BACKENDS, backend)

    if social_auth_backend and user_id and access_token:
            social_auth = social_auth_backend(strategy=load_strategy())
            user = social_auth.do_auth(access_token, response={'user_id': user_id})
 
    #... here comes non-relevant code

Could you help me resolve this issue?

Best regards,
Roman

Boboc Sabin

unread,
Jan 4, 2014, 11:43:47 PM1/4/14
to django-so...@googlegroups.com
Can you give an example how you have used dsa to authenticate mobile users, please !?
Thank you very much !


--
You received this message because you are subscribed to the Google Groups "Django Social Auth" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-social-a...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Karmadon

unread,
Jan 5, 2014, 4:53:24 AM1/5/14
to django-so...@googlegroups.com
Surely!

Here is my previous code simplified for tests:

@dsa_view
def test_mobile_auth(request, *args, **kwargs ):


    user_id = request.GET.get('user_id') or request.POST.get('user_id')
    access_token = request.GET.get('access_token')

    backend = get_backend('facebook', request, '')

    user = backend.do_auth(access_token, response={'user_id': user_id} )
    if user and user.is_active:
        login(request, user)

    return redirect('/')

And it worked just fine for authentication with Facebook and VK.

Thanks,
Roman
 
воскресенье, 5 января 2014 г., 6:43:47 UTC+2 пользователь Boboc Sabin написал:
To unsubscribe from this group and stop receiving emails from it, send an email to django-social-auth+unsub...@googlegroups.com.

Matías Aguirre

unread,
Jan 5, 2014, 10:41:56 AM1/5/14
to django-social-auth
Hi,

Try with this code instead https://gist.github.com/omab/8269742, you will see
that I'm passing some extra arguments to load_strategy().

Excerpts from Karmadon's message of 2014-01-04 08:53:50 -0200:
--
Matías Aguirre (matias...@gmail.com)

Karmadon

unread,
Jan 5, 2014, 4:56:23 PM1/5/14
to django-so...@googlegroups.com
Thank you very much! Now everything works like a charm!

Best regards,
Roman

воскресенье, 5 января 2014 г., 17:41:56 UTC+2 пользователь Matías Aguirre написал:
Reply all
Reply to author
Forward
0 new messages