2013-10-03 46 views
0

我一直在使用服務帳戶運行幾周的Ruby腳本,但今天我得到一個「無效請求」,當我嘗試構建客戶端使用以下功能:谷歌API客戶端突然回來與「無效請求」

def build_client(user_email) 
    client = Google::APIClient.new 
    client.authorization = Signet::OAuth2::Client.new(
    :token_credential_uri => 'https://accounts.google.com/o/oauth2/token', 
    :audience => 'https://accounts.google.com/o/oauth2/token', 
    :scope => 'https://www.googleapis.com/auth/calendar', 
    :issuer => SERVICE_ACCOUNT_EMAIL, 
    :signing_key => Google::APIClient::KeyUtils.load_from_pkcs12(SERVICE_ACCOUNT_PKCS12_FILE_PATH, "notasecret"), 
    :person => user_email 
) 
    client.authorization.fetch_access_token!  
    return client 
end 

服務帳戶是否有使用壽命?我試圖創建另一個服務帳戶,並使用它,但我得到了相同的結果:

Authorization failed. Server message: (Signet::AuthorizationError) 
{ 
    "error" : "invalid_request" 
} 

難住!

回答

0

好的。我想到了。這一切都與user_email有關。我正在從一個文件中讀取它,忘記了換行,所以它反對一個錯誤的電子郵件地址。

相關問題