1

OAuth2와 함께 Gdata Spreadsheet API를 사용하려고합니다. OAuth2.0에 된 ClientID를 사용스프레드 시트 API 사용 OAuth2 with Certificate 인증

는 그러나 서비스 계정을 사용하여/인증서 사용되는 400 잘못된 요청

스코프는

https://www.googleapis.com/auth/userinfo.email 
https://www.googleapis.com/auth/userinfo.profile 
https://www.googleapis.com/auth/admin.directory.group.readonly 
https://www.googleapis.com/auth/admin.directory.user.readonly 
https://docs.google.com/feeds/ 
https://spreadsheets.google.com/feeds 

enter image description here enter image description here

있는 원인 도메인에 OAuth2WebServerFlow와 함께 작동 다음은 현재 사용중인 코드입니다.

성공 : OAuth2.0에

flow = OAuth2WebServerFlow(client_id=CLIENT_ID, 
          client_secret=CLIENT_SECRET, 
          scope=SCOPE, 
          access_type = "online", 
          redirect_uri=REDIRECT_URI) 
credentials = flow.step2_exchange(code) 
auth2token = gauth.OAuth2Token(
          client_id=credentials.client_id, 
          client_secret=credentials.client_secret, 
          scope=SCOPE, 
          access_token=credentials.access_token, 
          refresh_token=credentials.refresh_token, 
          user_agent='spreadsheetclient/1.0',) 
client = SpreadsheetsClient(auth_token=auth2token) 
auth2token.authorize(client) 
q = SpreadsheetQuery(title= "ItemMaster",title_exact=True) 
feed = client.get_spreadsheets(query = q) 

credentials = SignedJwtAssertionCredentials(
         SERVICE_ACCOUNT_EMAIL, 
         CERTIFICATE, 
         scope = SCOPE, 
         prn = "[email protected]" 
         ) 
http = httplib2.Http() 
http = credentials.authorize(http) 
auth2token = gauth.OAuth2Token(
         client_id=credentials.client_id, 
         client_secret=credentials.client_secret, 
         scope=SCOPE, 
         access_token=credentials.access_token, 
         refresh_token=credentials.refresh_token, 
         user_agent='spreadsheetclient/1.0',) 
client = SpreadsheetsClient() 
auth2token.authorize(client) 
q = SpreadsheetQuery(title= "ItemMaster",title_exact=True,) 
feed = client.get_spreadsheets(query = q) 

그래서 Gdata는 API로 작업 인증서 인증을 얻을 수있는 방법이 OAuth2.0에 인증서 실패?

답변

4

나는 OAuth2TokenFromCredentials

credentials = SignedJwtAssertionCredentials(
        SERVICE_ACCOUNT_EMAIL, 
        PRIVATE_KEY, 
        scope = SCOPE, 
        sub = "[email protected]") 
    auth2token = gauth.OAuth2TokenFromCredentials(credentials) 
    client = SpreadsheetsClient() 
    auth2token.authorize(client) 
    q = SpreadsheetQuery(title= "ItemMaster",title_exact=True,) 
    feed = client.get_spreadsheets(query = q) 
    self.response.write(feed) 
를 사용하여 그것을 해결
관련 문제