Multiplex always returns 401 - Unauthorized


#1

I can’t seem to get the multiplex endpoint to return me anything but a 401 - Unauthorized. I have looked through all the documentation I can find and all of the information I can find around the net about Multiplexing, but nothing is obvious about what the issue may be.

Using the following curl command:

curl -v --location-trusted
-H “Content-Type:text/event-stream”
-H “Authorization: Bearer c.1234AB…XYZ, c.4321ZY…CBA”
-X GET “https://developer-api.nest.com/multiplex

I get the following returned:
Note: Unnecessary use of -X or --request, GET is already inferred.
* Trying 34.236.199.23…
* TCP_NODELAY set
* Connected to developer-api[dot]nest[dot]com (34.236.199.23) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
* subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=developer-api[dot]nest[dot]com
* start date: Aug 22 15:34:41 2017 GMT
* expire date: Aug 21 00:00:00 2018 GMT
* subjectAltName: host “developer-api[dot]nest[dot]com” matched cert’s “developer-api[dot]nest[dot]com”
* issuer: C=US; O=Google Inc; CN=Google Internet Authority G2
* SSL certificate verify ok.
> GET /multiplex HTTP/1.1
> Host: developer-api[dot]nest[dot]com
> User-Agent: curl/7.54.0
> Accept: /
> Content-Type:text/event-stream
> Authorization: Bearer c.1234AB…XYZ, c.4321ZY…CBA
>
< HTTP/1.1 401 Unauthorized
< Content-Type: application/json; charset=UTF-8
< Access-Control-Allow-Origin: *
< Cache-Control: private, no-cache, no-store, max-age=0
< Pragma: no-cache
< Connection: close
< content-length: 181
<
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):
{“error”:“unauthorized”,“type”:“https://developer.nest.com/documentation/cloud/error-messages#auth-error",“message”:“unauthorized”,“instance”:"28829e03-48fc-4bb5-b8e9-1d7e0235c609”}%


#2

You should be using header

-H “Accept:text/event-stream”

instead of

-H “Content-Type:text/event-stream”


#3

That did it. I think the multiplex example should be updated on https://developers.nest.com/documentation/cloud/how-to-read-data

Thanks for the quick response!


#4

Sorry about that @mgoodric, we’ll get the example in the docs updated.


#5

The example has been updated.