Hi folks,
I am trying to implement support for OAuth 2.0 bearer tokens in my Spray 0.9.0 application. One acceptable method of transmitting the OAuth access token is to use the "Authorization" header with the scheme "Bearer". However, the current bearer token specification (
http://self-issued.info/docs/draft-ietf-oauth-v2-bearer.html#authz-header) uses a different grammar than defined in RFC 2617:
The Authorization header field uses the framework defined by HTTP/1.1, Part 7 [I‑D.ietf‑httpbis‑p7‑auth] as follows:
credentials = "Bearer" 1*SP b64token
The b64token syntax was chosen over the alternative #auth-param syntax also defined by HTTP/1.1, Part 7 [I‑D.ietf‑httpbis‑p7‑auth] both for simplicity and for compatibility with existing implementations. If additional parameters are needed in the future, a different scheme would need to be defined.
So, for example, a client may send "Authorization: Bearer mF_9.B5f-4.1JqM" or "Authorization: Bearer /wz0rcb257M+f8i7tTWfRw==".
In AuthorizationHeader.scala, spray expects that the authorization scheme is followed by zero or more auth-param values (which it treats as key-value pairs).
This behavior is correct per section 1.2 of RFC 2617, which defines auth-param as token "=" ( token | quoted-string ). Unfortunately, this prevents me from accessing the OAuth token; when I run curl -v -H 'Authorization: Bearer mF_9.B5f-4.1JqM' http://localhost:8080 and print the list of headers, I receive "List(Host: localhost:8080, Accept: */*, Authorization: Bearer , User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5)".
Does anyone have any suggestions for how I can read the access token from my application? I tried turning on relaxed header parsing the result did not change (I do not receive warnings about the header being invalid.)
Thanks,
Alex