def decode_token(client_id, client_secret, token, token_type = "bearer", audience_ids = nil)
    reply = json_parse_reply(key_style, *request(target, :post, '/check_token',
                                                 Util.encode_form(:token => token),
                                                 "authorization" => Http.basic_auth(client_id, client_secret),
                                                 "content-type" => Http::FORM_UTF8,"accept" => Http::JSON_UTF8))

    auds = Util.arglist(reply[:aud] || reply['aud'])
    if audience_ids && (!auds || (auds & audience_ids).empty?)
      raise AuthError, "invalid audience: #{auds.join(' ')}"
    end
    reply
  end
def decode_token(client_id, client_secret, token, token_type = "bearer", audience_ids = nil)
    reply = json_parse_reply(key_style, *request(target, :post, '/check_token',
                                                 Util.encode_form(:token => token),
                                                 "authorization" => Http.basic_auth(client_id, client_secret),
                                                 "content-type" => Http::FORM_UTF8,"accept" => Http::JSON_UTF8))

    auds = Util.arglist(reply[:aud] || reply['aud'])
    if audience_ids && (!auds || (auds & audience_ids).empty?)
      raise AuthError, "invalid audience: #{auds.join(' ')}"
    end
    reply
  end
Sends +token+ to the server to validate and decode. Authenticates with
 +client_id+ and +client_secret+. If +audience_ids+ are specified and the
 token's "aud" attribute does not contain one or more of the audience_ids,
 raises AuthError -- meaning the token is not for this audience.
 @param (see Misc.server)
 @param [String] token an access token as retrieved by {TokenIssuer}. See
   also {TokenInfo}.
 @param [String] token_type as retrieved by {TokenIssuer}. See {TokenInfo}.
 @return [Hash] contents of the token