Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
BUG: SoundCloud API should be case insensitive
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
RF  
View profile  
 More options Feb 11 2011, 11:15 am
From: RF <rfist...@gmail.com>
Date: Fri, 11 Feb 2011 08:15:56 -0800 (PST)
Local: Fri, Feb 11 2011 11:15 am
Subject: BUG: SoundCloud API should be case insensitive
as per the HTTP1.1 spec:
http://tools.ietf.org/html/rfc2616#section-4.2

"Field names are case-insensitive."

e.g. This works
curl https://api.soundcloud.com/oauth2/token\
  -d 'client_id=xxx'\
  -d 'grant_type=authorization_code'\
  -d 'client_secret=yyy'\
  -d 'redirect_uri=appname://oauth-thing'\
  -d 'code=zzz'

but this does not
curl https://api.soundcloud.com/oauth2/token\
  -d 'Client_id=xxx'\
  -d 'Grant_type=authorization_code'\
  -d 'Client_secret=yyy'\
  -d 'Redirect_uri=appname://oauth-thing'\
  -d 'Code=zzz'

(you get {"error":"invalid_client"})

I don't personally care, but this non compliance means you can't use
the built in iOS classes to talk to SoundCloud as the url request
class stupidly (but legally!) upper cases the first letter of http
header fields.

This probably isn't the right place to log a bug, but it would be nice
to get a fix for this.

Cheers,
RF.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Stevenson-Leggett  
View profile   Translate to Translated (View Original)
 More options Feb 11 2011, 12:10 pm
From: Robert Stevenson-Leggett <rslegg...@googlemail.com>
Date: Fri, 11 Feb 2011 17:10:02 +0000
Local: Fri, Feb 11 2011 12:10 pm
Subject: Re: [SoundCloudAPI: 1474] BUG: SoundCloud API should be case insensitive

> stupidly (but legally!) upper cases the first letter of http
> header fields.

Interesting - I think this my problem - I keep getting invalid client
on windows using curl and fiddler2 - does this sound like these pieces
of software could uppercase the post variable names?

Rob
----
twitter: rsleggett

On 11 February 2011 16:15, RF <rfist...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RF  
View profile  
 More options Feb 11 2011, 12:32 pm
From: RF <rfist...@gmail.com>
Date: Fri, 11 Feb 2011 09:32:35 -0800 (PST)
Local: Fri, Feb 11 2011 12:32 pm
Subject: Re: BUG: SoundCloud API should be case insensitive

On Feb 11, 8:15 am, RF <rfist...@gmail.com> wrote:

For now I've worked around it by passing the fields in the URL (first
double checking that URL actually gets encrypted in https).

But still it'd would be nice if the API were fixed... and if Apple
didn't do this kind of thing.

RF.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ullrich Schäfer  
View profile  
 More options Feb 11 2011, 5:03 pm
From: Ullrich Schäfer <ullr...@soundcloud.com>
Date: Fri, 11 Feb 2011 23:03:32 +0100
Local: Fri, Feb 11 2011 5:03 pm
Subject: Re: [SoundCloudAPI: 1476] Re: BUG: SoundCloud API should be case insensitive
We're using Apples own NSURLConnection in the Cocoa API wrapper without problems. Can you use Charles to compare a working & a not working Request?

-Ullrich

Am 11.02.2011 um 18:32 schrieb RF <rfist...@gmail.com>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RF  
View profile  
 More options Feb 13 2011, 6:04 am
From: RF <rfist...@gmail.com>
Date: Sun, 13 Feb 2011 03:04:43 -0800 (PST)
Local: Sun, Feb 13 2011 6:04 am
Subject: Re: BUG: SoundCloud API should be case insensitive

On Feb 11, 11:03 pm, Ullrich Schäfer <ullr...@soundcloud.com> wrote:

> We're using Apples own NSURLConnection in the Cocoa API wrapper without problems. Can you use Charles to compare a working & a not working Request?

Your NSURLConnection implementation only works because you're passing
the header fields as multipart form data via [NSMutableURLRequest
setHTTPBodyStream] and NSMutableURLRequest doesn't mess around
multipart form data.

e.g.

    "Content-Type" = "multipart/form-data; boundary=------------nx-
oauth216807";
    "User-Agent" = "MacTestApp/1.0; SCSoundCloudAPI/2.0b6; Mac/i386;
Mac OS X/10.6.6; Darwin/10.6.0";
    --------------nx-oauth216807
    Content-Disposition: form-data; name="client_id"
    xxx
    --------------nx-oauth216807
    Content-Disposition: form-data; name="code"
    yyy

and so on.

Still, it would be really nice if the obvious implementation "just
worked":

  NSMutableURLRequest*  request = [[NSMutableURLRequest new]
autorelease];
  [request setHTTPMethod:@"POST"];

  NSDictionary* headers = [NSDictionary dictionaryWithObjectsAndKeys:
      SCAppClientID, @"client_id",
      SCAppClientSecret, @"client_secret",
      @"authorization_code", @"grant_type",
      SCAppURIRedirect, @"redirect_uri",
      auth_code, @"code",
      nil];

  [request setURL:[NSURL URLWithString:SCAuthTokenURL]];
  [request setAllHTTPHeaderFields:headers];

  [NSURLConnection connectionWithRequest:request delegate:self];

So whaddya say? How about making Sound Cloud HTTP 1.1 compliant?

It'll be good for Sound Cloud.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

Regards,
RF.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sean Treadway  
View profile  
 More options Feb 13 2011, 8:02 am
From: Sean Treadway <s...@soundcloud.com>
Date: Sun, 13 Feb 2011 14:02:27 +0100
Local: Sun, Feb 13 2011 8:02 am
Subject: Re: [SoundCloudAPI: 1480] Re: BUG: SoundCloud API should be case insensitive
Hi RF,

I'll address the subject, as I can't speak to what the Apple libraries
do to URL data.

It seems there is some confusion between HTTP header fields, and
application/x-www-form-urlencoded key value pairs.

You are correct that the header key value pairs part of an HTTP 1.1
message (after the request line and before the body) should be handled
as case-insensitive.  In our servers, we do treat these headers as
case-insensitive.

The curl example you gave does not add any headers (that's the -H
parameter), it only builds a URL encoded body for the POST you are
issuing.  The documentation for the '-d' parameter in the curl man
page:

"
(HTTP) Sends the specified data in a POST request to the HTTP server,
in the same way that a browser does when a user has  filled  in an
HTML form and presses the submit button. This will cause curl to pass
the data to the server using the content-type
application/x-www-form-urlencoded.
...
Thus,  using  '-d  name=daniel   -d   skill=lousy'   would   generate
 a   post   chunk   that   looks   like 'name=daniel&skill=lousy'.
"

So your two requests would look like this:

POST /oauth2/token HTTP/1.1
User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7
OpenSSL/0.9.8l zlib/1.2.3
Host: api.soundcloud.com
Accept: */*
Content-Length: 105
Content-Type: application/x-www-form-urlencoded

client_id=xxx&grant_type=authorization_code&client_secret=yyy&redirect_uri= appname://oauth-thing&code=zzz

Compared to:

POST /oauth2/token HTTP/1.1
User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7
OpenSSL/0.9.8l zlib/1.2.3
Host: api.soundcloud.com
Accept: */*
Content-Length: 105
Content-Type: application/x-www-form-urlencoded

Client_id=xxx&Grant_type=authorization_code&Client_secret=yyy&Redirect_uri= appname://oauth-thing&Code=zzz

The only fields that would qualify for case-insensitivity in rfc2616
would be "User-Agent, Host, Accept, Content-Length, Content-Type".

So we're really talking about making the query parameters to the OAuth
handshake case insensitive.

The OAuth2 spec isn't clear on whether or not the keys are expected to
be case-sensitive.

In the OAuth2 spec, there are some expected values that are explicitly
case-sensitive, so it's easy to infer that the keys are also assumed
to be case sensitive as they use the same characters in all examples.
I believe we are doing the right thing by assuming the keys to be
octets instead of character codes, and not accepting "Client_id" in
place of "client_id":
http://tools.ietf.org/html/draft-hammer-oauth2-00  Overall, case
sensitive keys reduces complexity.  Imagine how to explain all the
possible expected behaviors in the case of receiving
"Client_id=123&client_id=456".

As Ulrich suggested - the best thing for debugging network clients to
do is crack open HTTP requests with Charles to find the difference
between requests and what is getting put on the wire.
http://www.charlesproxy.com  Debugging data is usually gives the
fastest results.

Thanks for you suggestion, but we will stick with treating all
x-www-form-urlencoded keys as case-sensitive.

-Sean


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RF  
View profile  
 More options Feb 14 2011, 5:03 am
From: RF <rfist...@gmail.com>
Date: Mon, 14 Feb 2011 02:03:46 -0800 (PST)
Local: Mon, Feb 14 2011 5:03 am
Subject: Re: BUG: SoundCloud API should be case insensitive

On Feb 13, 2:02 pm, Sean Treadway <s...@soundcloud.com> wrote:

> Hi RF,

> I'll address the subject, as I can't speak to what the Apple libraries
> do to URL data.

> It seems there is some confusion between HTTP header fields, and
> application/x-www-form-urlencoded key value pairs.

Yes, I'm definitely confused (I'm not very http savvy). What I've been
talking about all along is HTTP header fields...

> You are correct that the header key value pairs part of an HTTP 1.1
> message (after the request line and before the body) should be handled
> as case-insensitive.  In our servers, we do treat these headers as
> case-insensitive.

> The curl example you gave does not add any headers (that's the -H
> parameter),

Oops, ok here's my corrected curl example, without any mixed case
keys:

curl https://api.soundcloud.com/oauth2/token -H 'client_id: xxx' \
 -H 'client_secret: yyy'\
 -H 'grant_type: authorization_code'\
 -H 'redirect_uri: appname://oauth-thing'\
 -H 'code: zzz' -d ""

(empty -d to get a POST instead of a GET)

And this doesn't work: {"error":"invalid_client"}, 401 Unauthorized.

I guess my question has become "should this work?".

If they're plain old vanilla HTTP header fields, then I guess they are
(hence my question above).

> In the OAuth2 spec, there are some expected values that are explicitly
> case-sensitive, so it's easy to infer that the keys are also assumed
> to be case sensitive as they use the same characters in all examples.
> I believe we are doing the right thing by assuming the keys to be
> octets instead of character codes, and not accepting "Client_id" in
> place of "client_id":http://tools.ietf.org/html/draft-hammer-oauth2-00 Overall, case
> sensitive keys reduces complexity.  Imagine how to explain all the
> possible expected behaviors in the case of receiving
> "Client_id=123&client_id=456".

tolower(key) wouldn't work? I'm probably missing something.

> As Ulrich suggested - the best thing for debugging network clients to
> do is crack open HTTP requests with Charles to find the difference
> between requests and what is getting put on the wire.http://www.charlesproxy.com Debugging data is usually gives the
> fastest results.

Nice - I've been using nc -l

> Thanks for you suggestion, but we will stick with treating all
> x-www-form-urlencoded keys as case-sensitive.

I've got nothing to say about x-www-form-urlencoded keys,
I just want to know if you can use HTTP header fields to authenticate
with sound cloud.
If you can then I want to know why my curl example doesn't work (and
then why the Apple equivalent doesn't work).

If you can't use the HTTP header fields, then I've got nothing to say
about anything.

RF.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sean Treadway  
View profile  
 More options Feb 14 2011, 5:41 am
From: Sean Treadway <s...@soundcloud.com>
Date: Mon, 14 Feb 2011 11:41:16 +0100
Local: Mon, Feb 14 2011 5:41 am
Subject: Re: [SoundCloudAPI: 1487] Re: BUG: SoundCloud API should be case insensitive
Hi RF,

On Mon, Feb 14, 2011 at 11:03 AM, RF <rfist...@gmail.com> wrote:
> curl https://api.soundcloud.com/oauth2/token -H 'client_id: xxx' \
>  -H 'client_secret: yyy'\
>  -H 'grant_type: authorization_code'\
>  -H 'redirect_uri: appname://oauth-thing'\
>  -H 'code: zzz' -d ""

> (empty -d to get a POST instead of a GET)

> And this doesn't work: {"error":"invalid_client"}, 401 Unauthorized.

> I guess my question has become "should this work?".

This will unfortunately not work.

When using these fields to authorize, they will need to be
x-www-form-urlencoded in the body or as query parameters in the URI as
described by:

http://tools.ietf.org/html/draft-hammer-oauth2-00#section-3.5.1

The OAuth2 spec does have a section for using HTTP headers for based
authorization:

http://tools.ietf.org/html/draft-hammer-oauth2-00#section-5.1

But this will only look for the authentication fields in the single
"Authorization" HTTP header.

As far as I can tell, there are no provisions in OAuth for getting a
token from passing the client_id and other URI parameters as HTTP
headers.

It sounds like it'd be convenient to treat the HTTP headers as URI
parameters for your tools, but I'm sure there are some other tools
that will help you construct urlencoded query strings too.

Happy hacking and I hope this explanation helps when using the SoundCloud API.

-Sean


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RF  
View profile  
 More options Feb 16 2011, 4:14 pm
From: RF <rfist...@gmail.com>
Date: Wed, 16 Feb 2011 13:14:16 -0800 (PST)
Local: Wed, Feb 16 2011 4:14 pm
Subject: Re: BUG: SoundCloud API should be case insensitive

On Feb 14, 11:41 am, Sean Treadway <s...@soundcloud.com> wrote:

I see.

> The OAuth2 spec does have a section for using HTTP headers for based
> authorization:

> http://tools.ietf.org/html/draft-hammer-oauth2-00#section-5.1

> But this will only look for the authentication fields in the single
> "Authorization" HTTP header.

Ah.

> As far as I can tell, there are no provisions in OAuth for getting a
> token from passing the client_id and other URI parameters as HTTP
> headers.

> It sounds like it'd be convenient to treat the HTTP headers as URI
> parameters for your tools, but I'm sure there are some other tools
> that will help you construct urlencoded query strings too.

It's no big deal - I was just under the mistaken impression that
arguments passed as
a) part of the URL, b) as HTTP header fields and c) as form data were
all equivalent
and so it seemed wrong that b) should not work.

Thanks!
RF.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »