0

Django-socila-auth pluginを使用しています。Oauth 1.0 認証に Google API を使用します。質問は、Google python API (gdata) で使用した人がいるかどうかです。django-social-auth モデルに保存されている auth session_token を API 呼び出しに適用する方法を意味します。

モデルからこのトークンを取得して gdata.PhotoService() インスタンスに適用するコードを教えてください。今のところ、次のようになっています。

        #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')

エラーが表示されます

403 Invalid token string.

シークレットも必要なのはわかるのですが、認証用のAPIに適用するにはどうすればいいですか?ところで、social-auth がパーミッションを要求するためのオプション文字列として Picassa フィードの URL を追加したので、Google で認証するときに Picassa フィードのパーミッションを要求するトークンがあります。

ところで。私が使用したGoogleチュートリアルは次のとおりです。ここ では、AusSubではなくOauth 1.0であることを理解していますが、質問は次のとおりです。

私が持っているトークンと秘密で認証し、この許可で写真を投稿する方法は?

4

1 に答える 1