Question

I'm using Django-socila-auth plugin. It uses google API for Oauth 1.0 Authentication. Question is have anybody used it with google python API (gdata). I mean how to apply auth session_token, stored in django-social-auth model to my api call.

Can you help me with code to get this token from model and apply to gdata.PhotoService() instance. For now it is like this:

        #getting model instance from django-social-auth model
        association = Association.objects.get(user=request.user)
        
        google_session_token=association.handle
        google_secret=association.secret
        
        #token string from django-social-auth 
        #model Association field "handle" looks like:
        #google_session_token = '.......XG84PjwytqJkvr8WQhDxm1w-JplWK5zPndSHB13f.........'
        
        gd_client = gdata.photos.service.PhotosService()
        gd_client.debug = 'true'
        gd_client.auth_token = google_session_token
        #image.image is a file field, but problem not in this.
        #it tries to send file in debug text. 
        #It just recieves 403 unauthorised callback.
        photo = gd_client.InsertPhotoSimple(
            '/data/feed/api/user/default/albumid/default', 'New Photo', 
            'Uploaded using the API', image.image, content_type='image/jpeg')

I'm recieving error

403 Invalid token string.

I understand that it needs secret too but how to apply it to API for auth?(To receive authorization to post photos.). BTW I added Picassa feed URL, as an option string for social-auth to ask permissions, so token I have asks for Picassa feed permissions when authorizing with google.

BTW. Google tutorial I've used is: here I understand it's Oauth 1.0 rather than AusSub, but question is:

how to authenticate with token and secret I have and post a photo with this permission?

Was it helpful?

Solution

Just to answer my own problem. I used wrong way to do it, because problem in 'gd_client' and AuthSub. It must check token on server. And it can not do it on localhost. You need to look ahead to Oauth/Oauth2 for better debugging and so on... No matter that it is much complex than AuthSub

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top