Skip to content

Support for OAUTHBEARER as per RFC 7628  #2487

@PMox

Description

@PMox

I did this

curl "imaps://imap.gmail.com:993" --user "XXX" --oauth2-bearer "ya29.XXX"

CURL is sending this:

A002 AUTHENTICATE OAUTHBEARER __REDACTED__

GMail IMAP is answering with:

A002 BAD Invalid SASL argument. i29mb53490361edj

Decoding the token:

pbpaste | base64 -D | python2 -c 'import sys; a=sys.stdin.read(); print repr(a)'

Generate this:

user=user@domain.com\x01host=imap.gmail.com\x01port=993\x01auth=Bearer ya29.XXX\x01\x01

As per RFC 7628 I think this is not correct, and I would expect the token to be formatted in this way:

n,a=user@domain.com,\x01host=imap.gmail.com\x01port=993\x01auth=Bearer ya29.XXX\x01\x01

If I provide this to GMail, it works.

The syntax with simply user=,auth= is suitable for method XOAUTH2 instead.

I tried to generate the different syntax and then try directly with OpenSSL to confirm what works and what not.

I expected the following

Unless there are other RFC outdating RFC 7628 (which I didn't found), I would expect cURL to do one of the following:

  1. use XOAUTH2 with current format
  2. or OAUTHBEARER with the syntax documented in RFC 7628
  3. or anyway allow to force a given SAML auth mechanism

Workaround (partial) is to use a request in the form:

-X "AUTHENTICATE XOAUTH2 __REDACTED__"
-X "AUTHENTICATE OAUTHBEARER __REDACTED__"

but it seems cURL supports only one request at a time, so this would will not play well with a folder listing operation.

curl/libcurl version

curl 7.54.0 (x86_64-apple-darwin17.0) libcurl/7.54.0 LibreSSL/2.0.20 zlib/1.2.11 nghttp2/1.24.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz HTTP2 UnixSockets HTTPS-proxy

curl 7.59.0 (x86_64-apple-darwin17.3.0) libcurl/7.59.0 SecureTransport zlib/1.2.11
Release-Date: 2018-03-14
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile NTLM NTLM_WB SSL libz UnixSockets

operating system

Mac OS 10.13.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions