Re: [OAUTH-WG] application/x-www-form-urlencoded vs JSON (Proposal)

Robert Sayre <sayrer@gmail.com> Fri, 07 May 2010 17:26 UTC

Return-Path: <sayrer@gmail.com>
X-Original-To: oauth@core3.amsl.com
Delivered-To: oauth@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 4DD603A6876 for <oauth@core3.amsl.com>; Fri, 7 May 2010 10:26:11 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.904
X-Spam-Level:
X-Spam-Status: No, score=-2.904 tagged_above=-999 required=5 tests=[AWL=-0.719, BAYES_40=-0.185, GB_I_LETTER=-2]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bCy-oeHEjFFd for <oauth@core3.amsl.com>; Fri, 7 May 2010 10:26:10 -0700 (PDT)
Received: from mail-qy0-f181.google.com (mail-qy0-f181.google.com [209.85.221.181]) by core3.amsl.com (Postfix) with ESMTP id F108E3A69C9 for <oauth@ietf.org>; Fri, 7 May 2010 10:24:26 -0700 (PDT)
Received: by qyk11 with SMTP id 11so1886298qyk.13 for <oauth@ietf.org>; Fri, 07 May 2010 10:24:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=WgvWtsIxnJMR2nmrTIpSFM8EPHrnebi+Kq9XXg4zpiA=; b=UsLoXt5BC03dDMoMf/ElQ5fCHE0ohLgE2vyG8n2cZ6NRIqik7m1xpgf7e2uU34oz5Y 50j2MG9YsP7cY3pW17L/MpbRNVAIQZbxNx09K5YJsBarSy61iEsDJQPHyea13uFQU7fW whAQHyPpE31mkyRUmYTU16shdwfd/rS2dxXJk=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=DumYniRy27NqmyRu4e2AJYxBbZDKYWAucapwAm/zOesnwZakTA+JOxYg0LCs8lmGA8 J66vRxrYIBrB/ADdmB5iG1aQ7DufZWm6u6qUlTU74xb0o/yAUrga9O9TUp8/Qh3LQJrd j2JoIYJvX/PSs4sFaesmsTaOgoAsgiJKPx1Pg=
MIME-Version: 1.0
Received: by 10.229.250.78 with SMTP id mn14mr274776qcb.16.1273253050557; Fri, 07 May 2010 10:24:10 -0700 (PDT)
Received: by 10.229.99.142 with HTTP; Fri, 7 May 2010 10:24:10 -0700 (PDT)
In-Reply-To: <90C41DD21FB7C64BB94121FBBC2E72343932484ADD@P3PW5EX1MB01.EX1.SECURESERVER.NET>
References: <9890332F-E759-4E63-96FE-DB3071194D84@gmail.com> <90C41DD21FB7C64BB94121FBBC2E723438E30A379B@P3PW5EX1MB01.EX1.SECURESERVER.NET> <20100419134825.134951nuzvi35hk4@webmail.df.eu> <90C41DD21FB7C64BB94121FBBC2E723438E5C7F45E@P3PW5EX1MB01.EX1.SECURESERVER.NET> <4BD2A172.2070401@lodderstedt.net> <4BD8869A.2080403@lodderstedt.net> <s2zc334d54e1004281425x5e714eebwcd5a91af593a62ac@mail.gmail.com> <v2j68fba5c51004282044o3a5f96cfucb1157d3884d8cd2@mail.gmail.com> <4BD9E1E3.7060107@lodderstedt.net> <90C41DD21FB7C64BB94121FBBC2E72343932484ADD@P3PW5EX1MB01.EX1.SECURESERVER.NET>
Date: Fri, 07 May 2010 13:24:10 -0400
Message-ID: <h2u68fba5c51005071024s80cdb02le4dfbe40db06c218@mail.gmail.com>
From: Robert Sayre <sayrer@gmail.com>
To: Eran Hammer-Lahav <eran@hueniverse.com>
Content-Type: text/plain; charset="ISO-8859-1"
Cc: "oauth@ietf.org" <oauth@ietf.org>
Subject: Re: [OAUTH-WG] application/x-www-form-urlencoded vs JSON (Proposal)
X-BeenThere: oauth@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: OAUTH WG <oauth.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/oauth>, <mailto:oauth-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/oauth>
List-Post: <mailto:oauth@ietf.org>
List-Help: <mailto:oauth-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/oauth>, <mailto:oauth-request@ietf.org?subject=subscribe>
X-List-Received-Date: Fri, 07 May 2010 17:26:11 -0000

On Fri, May 7, 2010 at 11:28 AM, Eran Hammer-Lahav <eran@hueniverse.com> wrote:
>
> Again, for the server, this is just a single printf() statement per format:
>
> printf("{\"access_token\":\"%s\",\"expires_in\":%d}", token, expires);
> printf("<oauth><access_token>%s</access_token><expires_in>%d</expires_in></oauth>", token, expires);
>
> For the client, if they don't like the default, you can use the Accept header or a 'format' query parameter.
>
> Show me where this is more complex!

You can't actually use printf to produce this output in any quality
implementation, especially if you want to support extension
parameters. Using printf will get you at least three varieties of
escaping bugs, so you'll need special libraries to generate each
format.

I think form-encoding is OK if the WG knows that these response bodies
will never need to be complex, and never contain more than ASCII.

If these need more than ASCII, you'll be relying on everyone to use
the same (unspecified, btw) input encoding before they produce their
form-encoded string. You're still going to have to spec an encoding
param or make all implementations promise to use UTF-8 prior to URL
encoding. Neither of those strategies will work very well. That said,
the spec already has this problem elsewhere, so using JSON here won't
fix it entirely.

Also, adding something complex to a form-encoded response will get
pretty ugly, since you'll need a namespace-like thing prepended to
each field name.

-- 

Robert Sayre

"I would have written a shorter letter, but I did not have the time."