0

サービス アカウントを使用して数週間 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"
}

困った!

4

1 に答える 1