data.photos.service.PhotosService
을 사용하여 Picasa에서 사진을 가져오고 당길 수 있습니다. 나는 Google 콘솔에서 서비스 키 파일 XXXXXXXX-privatekey.p12를 얻었으며 지금은 Google과 함께 키를 사용하여 인증을 시도하고 있습니다.python의 gdata에서 OAuth2 서비스 계정 사용
f = file(settings.SITE_ROOT + '/aurora/' + settings.PRIVATE_KEY, 'rb')
key = f.read()
f.close()
credentials = SignedJwtAssertionCredentials(settings.SERVICE_ACCOUNT_NAME, key, scope = 'http://picasaweb.google.com/data https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile')
http = httplib2.Http()
http = credentials.authorize(http)
service = build("oauth2", "v2", http=http)
user_info = None
try:
user_info = service.userinfo().get().execute()
# neither of these two methods work
#gd_client.SetOAuthInputParameters(signature_method = gdata.auth.OAuthSignatureMethod.RSA_SHA1, consumer_key = "asdfasdfasdf.apps.googleusercontent.com", rsa_key = key, two_legged_oauth = True, requestor_id = user_info.get('email'))
#gd_client.auth_token = gdata.gauth.TwoLeggedOAuthRsaToken(consumer_key = user_info.get('email'), rsa_private_key = key, requestor_id = user_info.get('email'))
except errors.HttpError, e:
logging.error('An error occurred: %s', e)
user_inf0 = {u'verified_email': True, u'id': u'1234', u'name': u'[email protected]', u'email': u'[email protected]'}
문제는 방법 중 하나 SetOAuthInputParameters
를 사용하여 2 리턴한다을 유효하지 않은 토큰, 또는 방법을 반환한다는 것입니다 :
OAUTH2 사용에서 appengine에 대한 문서는 다음을 사용하는 것이 유용 할 것이라고 믿고 저를 주도하고있다 403 restricted
.
나는 지혜로운 끝에서 모든 사람들이 규칙적으로 3 발의 oauth 코드를 읽는 것을 정말로 읽고 정말로 그렇게하지 않으려 고합니다. 아직 보지 못한 아이디어 나 기사는 없습니까?
어떻게 'SignedJwtAssertionCredentials' 호출에서 사용자를 지정 했습니까? – Gautam
답변을 업데이트했습니다. –
계속 HTTP 400을 받고 있는데 스프레드 시트 API를 사용하고 있습니다 – Gautam