我已经使用服务帐户运行Ruby脚本好几周了,但是今天当我尝试使用以下函数构建客户机时,我收到了一个“无效请求”:
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"
}绊倒了!
发布于 2013-10-03 20:18:40
好的。我想通了。这都与user_email有关。我是从一个文件中读到的,却忘了把这条线信息删除,所以它反对一个不正常的电子邮件地址。
https://stackoverflow.com/questions/19167554
复制相似问题