无效的客户端类型,使用google oauth获取有限输入设备的验证码

时间:2018-02-23 14:38:09

标签: authentication curl cors google-oauth

我正在尝试为有限的输入设备添加谷歌登录,如针对Web应用程序类型所述here

使用我的client_id我无法获取验证码,因为我一直收到此错误:

$> curl -d "client_id=887293527777-tf5uf5q5skss8sbktp1vpo67p2v5b7i7.apps.googleusercontent.com&scope=email%20profile" https://accounts.google.com/o/oauth2/device/code
{
  "error" : "invalid_client",
  "error_description" : "Invalid client type."
}

详细输出:

$> curl -d "client_id=887293527777-tf5uf5q5skss8sbktp1vpo67p2v5b7i7.apps.googleusercontent.com&scope=email%20profile" https://accounts.google.com/o/oauth2/device/code -vvv
*   Trying 209.85.203.84...
* TCP_NODELAY set
* Connected to accounts.google.com (209.85.203.84) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* ALPN, server accepted to use h2
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
*       subject: CN=accounts.google.com,O=Google Inc,L=Mountain View,ST=California,C=US
*       start date: Feb 07 21:22:30 2018 GMT
*       expire date: May 02 21:11:00 2018 GMT
*       common name: accounts.google.com
*       issuer: CN=Google Internet Authority G2,O=Google Inc,C=US
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x56450ea69cd0)
> POST /o/oauth2/device/code HTTP/1.1
> Host: accounts.google.com
> User-Agent: curl/7.51.0
> Accept: */*
> Content-Length: 104
> Content-Type: application/x-www-form-urlencoded
> 
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* We are completely uploaded and fine
< HTTP/2 401 
< content-type: application/json; charset=utf-8
< x-content-type-options: nosniff
< cache-control: no-cache, no-store, max-age=0, must-revalidate
< pragma: no-cache
< expires: Mon, 01 Jan 1990 00:00:00 GMT
< date: Fri, 23 Feb 2018 14:29:41 GMT
< server: ESF
< x-xss-protection: 1; mode=block
< x-frame-options: SAMEORIGIN
< alt-svc: hq=":443"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=":443"; ma=2592000; v="41,39,38,37,35"
< accept-ranges: none
< vary: Accept-Encoding
< 
{
  "error" : "invalid_client",
  "error_description" : "Invalid client type."
* Curl_http_done: called premature == 0
* Connection #0 to host accounts.google.com left intact
}

这真令人讨厌,因为他们在他们的指南上给出了卷曲的例子。我也尝试过javascript,但没有运气。

编辑:我可以使用其他作为类型卷曲,所以我不认为问题在我身边,但使用其他对我不好,因为我需要使用Web应用程序来设置CORS。

1 个答案:

答案 0 :(得分:1)

该流程仅支持客户端类型&#34;其他&#34;。见https://developers.google.com/identity/sign-in/devices#get_a_client_id_and_client_secret