2011-08-19 4 views
0

나는 을 사용하고 있습니다. Oauth 1.0 인증을 위해 Google API를 사용합니다. 질문은 아무도 Google 파이썬 API (gdata)와 함께 사용했습니다. 나는 auth session_token을 django-social-auth 모델에 저장하여 api 호출에 적용하는 것을 의미한다.Django-social-auth google oauth 토큰 사용

모델에서이 토큰을 가져 와서 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') 

내가 사진을 게시 할 수도 있지만, 인증을위한 API에 적용하는 방법 (수신하려면 비밀 인증이 필요하다는 것을 이해

403 Invalid token string. 

?). BTW Picassa 피드 URL을 소셜 시큐리티에 대한 옵션 문자열로 추가하여 권한을 요청 했으므로 Google에서 승인 할 때 Picassa 피드 권한을 요청한 토큰이 있습니다.

BTW. 내가 사용했던 구글의 튜토리얼은 다음과 같습니다 here 나는 그것을 OAuth를 1.0보다는 AusSub의 이해하지만 질문은 :

방법 토큰과 내가 가진이 권한을 가진 사진을 게시 비밀로 인증?

+0

은 Google 캘린더와 비슷한 문제가 있습니다. 토큰을 올바르게 사용하도록 코드를 가져올 수 없습니다. 이 방법을 사용할 수있는 방법을 찾았습니까? – Kai

답변

0

내 문제에 대한 답변입니다. 'gd_client'와 AuthSub의 문제 때문에 잘못된 방법을 사용했습니다. 서버의 토큰을 확인해야합니다. 그리고 그것은 localhost에서 할 수 없습니다. 더 나은 디버깅을 위해 Oauth/Oauth2를 바라 볼 필요가 있습니다. ... AuthSub보다 훨씬 복잡합니다.