Skip to content

Instantly share code, notes, and snippets.

@mouseos
Last active January 23, 2024 15:31
Show Gist options
  • Save mouseos/f91d360a20dee321881eabdbcde6172a to your computer and use it in GitHub Desktop.
Save mouseos/f91d360a20dee321881eabdbcde6172a to your computer and use it in GitHub Desktop.

スマホ側でパケットキャプチャして実験

端末の追加(初期設定)

デフォルトの日本設定の場合

この場合naverサーバーにclient_idが存在せず失敗する

request

curl -H "Content-Type: application/json" \
     -H "User-Agent: ClovaApp/Android/3.7.7 (Android 13;motorola edge 20 pro;other=qcom;pkg=com.naver.nozzle;clovasdk=27.2232.706)" \
     -H "Authorization: Bearer AAAAPQk3pC4bryxAiiI_mYEIDXsnXhxBO-ExUIqRnP725E77PI1i-W1djOSpq8HnBtlXrG_FyYB3JCh2KaKFjKmPJ1E" \
     -H "Host: auth.clova.ai" --compressed \
     "https://auth.clova.ai/authorize?device_id=3fd945b20c40473d986e14c69e2fb9a6bae10443becbba3450b504c09c735fca&response_type=code&model_id=NL-V110JP&state=F2BouRnRJfJW%2FkTVMHY8RA%3D%3D&client_id=sA61n2dSiCu5i6nCtAC3bEGYRlRVLHw8"

response

client_idが日本のままなので拒否された

{
	"error": "invalid_request",
	"error_description": "invalid client_id : sA61n2dSiCu5i6nCtAC3bEGYRlRVLHw8"
}

#naverサーバーに変更後 clovadevice://server_setting/20をsend schemeするとnaver betaサーバーになる。 この場合ログイン後正常に動かない。 clovadevice://server_setting/0で製品版サーバーになり正常動作する。 request

curl -H "Content-Type: application/json" \
     -H "User-Agent: ClovaApp/Android/3.7.7 (Android 13;motorola edge 20 pro;other=qcom;pkg=com.naver.nozzle;clovasdk=27.2232.706)" \
     -H "Authorization: Bearer AAAAPQk3pC4bryxAiiI_mYEIDXsnXhxBO-ExUIqRnP725E77PI1i-W1djOSpq8HnBtlXrG_FyYB3JCh2KaKFjKmPJ1E" \
     -H "Host: auth.clova.ai" --compressed \
     "https://auth.clova.ai/authorize?device_id=3fd945b20c40473d986e14c69e2fb9a6bae10443becbba3450b504c09c735fca&response_type=code&model_id=NL-V110JP&state=hQ%2FtamTiiqL%2BTKwt5iacmA%3D%3D&client_id=80b20025d7aaf44a20f193851fe00354"

これでもOK

curl -H 'Accept: application/json' \
     -H "Authorization: Bearer AAAAPQk3pC4bryxAiiI_mYEIDXsnXhxBO-ExUIqRnP725E77PI1i-W1djOSpq8HnBtlXrG_FyYB3JCh2KaKFjKmPJ1E" \
     "https://auth.clova.ai/authorize?client_id=80b20025d7aaf44a20f193851fe00354&device_id=3fd945b20c40473d986e14c69e2fb9a6bae10443becbba3450b504c09c735fca&model_id=NL-V110JP&response_type=code&state=FKjaJfMlakjdfTVbES5ccZ"

response

{
  "agreements": {
    "terms": {
      "agreed": true,
      "agreement_date": "2023-08-01T00:52:03+09:00",
      "required": true
    },
    "personal_info": {
      "agreed": true,
      "agreement_date": "2023-08-01T00:52:03+09:00",
      "required": true
    },
    "address_book": {
      "agreed": true,
      "agreement_date": "2023-08-01T00:52:03+09:00",
      "required": false
    },
    "adult": {
      "agreed": false,
      "required": false
    },
    "personal_address": {
      "agreed": true,
      "agreement_date": "2024-01-19T21:09:52+09:00",
      "required": false
    },
    "push": {
      "agreed": true,
      "agreement_date": "2023-08-01T00:52:03+09:00",
      "required": false
    },
    "uplus": {
      "agreed": false,
      "required": false
    },
    "genie": {
      "agreed": false,
      "required": false
    },
    "naver_cloud": {
      "agreed": true,
      "agreement_date": "2024-01-19T21:09:52+09:00",
      "required": true
    },
    "kids_info": {
      "agreed": false,
      "required": false
    },
    "woongjin": {
      "agreed": false,
      "required": false
    }
  },
  "code": "EQHNXTJ_RSi401uM10FuEA",
  "state": "FKjaJfMlakjdfTVbES5ccZ"
}

clovadevice://server_setting/0実行でnaverサーバーに変更後

request

curl -H "Content-Type: application/json" -H "User-Agent: ClovaApp/Android/3.7.7 (Android 13;motorola edge 20 pro;other=qcom;pkg=com.naver.nozzle;clovasdk=27.2232.706)" -H "Authorization: Bearer AAAAPQk3pC4bryxAiiI_mYEIDXsnXhxBO-ExUIqRnP725E77PI1i-W1djOSpq8HnBtlXrG_FyYB3JCh2KaKFjKmPJ1E" -H "Host: auth.clova.ai" --compressed "https://auth.clova.ai/authorize?device_id=3fd945b20c40473d986e14c69e2fb9a6bae10443becbba3450b504c09c735fca&response_type=code&model_id=NL-V110JP&state=Q5ciVGKqi2BmtAUbFf3fMw%3D%3D&client_id=80b20025d7aaf44a20f193851fe00354"

response

{
  "agreements": {
    "terms": {
      "agreed": true,
      "agreement_date": "2023-08-01T00:52:03+09:00",
      "required": true
    },
    "personal_info": {
      "agreed": true,
      "agreement_date": "2023-08-01T00:52:03+09:00",
      "required": true
    },
    "address_book": {
      "agreed": true,
      "agreement_date": "2023-08-01T00:52:03+09:00",
      "required": false
    },
    "adult": {
      "agreed": false,
      "required": false
    },
    "personal_address": {
      "agreed": true,
      "agreement_date": "2024-01-19T21:09:52+09:00",
      "required": false
    },
    "push": {
      "agreed": true,
      "agreement_date": "2023-08-01T00:52:03+09:00",
      "required": false
    },
    "uplus": {
      "agreed": false,
      "required": false
    },
    "genie": {
      "agreed": false,
      "required": false
    },
    "naver_cloud": {
      "agreed": true,
      "agreement_date": "2024-01-19T21:09:52+09:00",
      "required": true
    },
    "kids_info": {
      "agreed": false,
      "required": false
    },
    "woongjin": {
      "agreed": false,
      "required": false
    }
  },
  "code": "5ueMo5tFQwSYW-qhhVB7Eg",
  "state": "Q5ciVGKqi2BmtAUbFf3fMw=="
}

デバイス情報

request

curl -H "Host: prod-ni-cic.clova.ai" -H "content-type: application/json; charset=utf-8" -H "date: 2024-01-23T22:41:35+09:00" -H "user-agent: ClovaApp/Android/3.7.7- (Android OS 13;motorola edge 20 pro;pkg=com.naver.nozzle)" -H "accept-language: ko-KR" -H "authorization: Bearer 59in5EmmQO2X5ZCWRRsOmA" --compressed "https://prod-ni-cic.clova.ai/api/v1/user/devices"

response(緯度と経度は省略)

{
  "meta": {
    "success": true,
    "error": null,
    "errorCode": null
  },
  "result": [
    {
      "availabilities": [
        {
          "name": "DELEGATION",
          "available": true
        },
        {
          "name": "AUDIOPLAYER_EXPOSE",
          "available": true
        },
        {
          "name": "AUDIOPLAYER_CONTROL",
          "available": true
        },
        {
          "name": "SPEAKER_REGISTRATION",
          "available": true
        },
        {
          "name": "AUDIOPLAYER_CONTROL_NAVIGATE",
          "available": true
        },
        {
          "name": "CALENDAR_AVAILABLE",
          "available": true
        }
      ],
      "clientName": "DESK",
      "clientId": "80b20025d7aaf44a20f193851fe00354",
      "deviceId": "3fd945b20c40473d986e14c69e2fb9a6bae10443becbba3450b504c09c735fca",
      "deviceName": "CLOVA-DESK-9CC",
      "deviceImageUrl": null,
      "modelId": "NL-V110JP",
      "manufacturerName": null,
      "userGuideUrl": null,
      "websiteUrl": null,
      "customerCenterUrl": null,
      "companionAppUrl": null,
      "voiceType": "",
      "is3rdParty": false,
      "location": {
        "latitude": "",
        "longitude": "",
        "address": ""
      },
      "bindTime": "2024-01-23T22:42:43+09:00",
      "configuration": {
        "DeviceInfoDefinedName": "사무실 DESK",
        "KeywordCurrent": "JP01"
      }
    },
    {
      "availabilities": [
        {
          "name": "DELEGATION",
          "available": true
        },
        {
          "name": "AUDIOPLAYER_EXPOSE",
          "available": true
        },
        {
          "name": "AUDIOPLAYER_CONTROL",
          "available": true
        },
        {
          "name": "SPEAKER_REGISTRATION",
          "available": true
        },
        {
          "name": "AUDIOPLAYER_CONTROL_NAVIGATE",
          "available": true
        },
        {
          "name": "CALENDAR_AVAILABLE",
          "available": true
        }
      ],
      "clientName": "FRIENDS_BROWN",
      "clientId": "dade0b2bc39a4d7bb73138600558b3b8",
      "deviceId": "2e336c65679694512cbb526b2cac404d645270b0e6d0f9e830fac04f20a290ac",
      "deviceName": "CLOVA-SALLY-3D2",
      "deviceImageUrl": null,
      "modelId": "NL-S110JP",
      "manufacturerName": null,
      "userGuideUrl": "https://clova.ai/m/ko/guide/",
      "websiteUrl": "https://clova.ai/ko/ko-product-friends.html",
      "customerCenterUrl": "https://clova.ai/m/ko/ko-product-friends.html#cs",
      "companionAppUrl": null,
      "voiceType": "",
      "is3rdParty": false,
      "location": {
        "latitude": "dummy",
        "longitude": "dummy",
        "address": ""
      },
      "bindTime": "2024-01-20T00:50:01+09:00",
      "configuration": {
        "DeviceInfoDefinedName": "CLOVA-SALLY-3D2",
        "KeywordCurrent": "nee_clova"
      }
    }
  ]
}

デバイスの設定変更

cic apiを用いて設定変更ができる。一部隠し項目がありdpi変更やcic applicationsなど用途不明機能がある。 https://developers.naver.com/console/clova/client/Develop/References/CIC_API.md#SendEvent

curl -H "Host: prod-ni-cic.clova.ai" -H "authorization: Bearer 59in5EmmQO2X5ZCWRRsOmA" -H "user-agent: ClovaApp/Android/3.7.7 (Android 13;motorola edge 20 pro;other=qcom;pkg=com.naver.nozzle;clovasdk=27.2232.706)" -H "content-type: multipart/form-data; boundary=ad551432-63a2-437e-8c09-782dbf861a7c" --data-binary "--ad551432-63a2-437e-8c09-782dbf861a7c
Content-Type: application/json; charset=utf-8
Content-Length: 6916

ここにjsonを入れる
" --compressed "https://prod-ni-cic.clova.ai/v1/events"

送るjson

--2b935de8-c205-496b-b494-5f7b42f7223b
Content-Type: application/json; charset=utf-8
Content-Length: 6773

{
    "context": [
        {
            "header": {
                "namespace": "Alerts",
                "name": "AlertsState"
            },
            "payload": {
                "activeAlerts": [
                ],
                "allAlerts": [
                ]
            }
        },
        {
            "header": {
                "namespace": "AudioPlayer",
                "name": "PlaybackState"
            },
            "payload": {
                "offsetInMilliseconds": 0,
                "playerActivity": "IDLE",
                "repeatMode": "NONE",
                "totalInMilliseconds": 0
            }
        },
        {
            "header": {
                "namespace": "SpeechSynthesizer",
                "name": "SpeechState"
            },
            "payload": {
                "playerActivity": "",
                "token": ""
            }
        },
        {
            "header": {
                "namespace": "Device",
                "name": "Display"
            },
            "payload": {
                "contentLayer": {
                    "width": 1080,
                    "height": 2190
                },
                "dpi": 400,
                "orientation": "portrait",
                "size": "custom"
            }
        },
        {
            "header": {
                "namespace": "Clova",
                "name": "Location"
            },
            "payload": {
                "latitude": "dummy",
                "longitude": "dummy",
                "refreshedAt": "2024-01-23T22:39:31+09:00"
            }
        },
        {
            "header": {
                "namespace": "Speaker",
                "name": "VolumeState"
            },
            "payload": {
                "muted": true,
                "volume": 0
            }
        },
        {
            "header": {
                "namespace": "CDK",
                "name": "Applications"
            },
            "payload": {
                "applications": [
                ]
            }
        },
        {
            "header": {
                "namespace": "Device",
                "name": "Audio"
            },
            "payload": {
                "acceptContentType": [
                    {
                        "audioCodec": "MP3",
                        "fileExtension": "MP3,TS",
                        "mimeType": "audio/mpeg"
                    },
                    {
                        "audioCodec": "AAC",
                        "fileExtension": "3GP,MP4,M4A,AAC,TS",
                        "mimeType": "audio/aac"
                    },
                    {
                        "audioCodec": "MP3",
                        "fileExtension": "MP3,TS",
                        "mimeType": "audio/mpegurl"
                    },
                    {
                        "audioCodec": "MP3",
                        "fileExtension": "MP3,TS",
                        "mimeType": "application/vnd.apple.mpegurl"
                    },
                    {
                        "audioCodec": "AAC",
                        "fileExtension": "3GP,MP4,M4A,AAC,TS",
                        "mimeType": "application/vnd.apple.mpegurl"
                    }
                ]
            }
        },
        {
            "header": {
                "namespace": "Device",
                "name": "DeviceState"
            },
            "payload": {
                "airplane": {
                    "actions": [
                        "TurnOff",
                        "TurnOn"
                    ],
                    "state": "off"
                },
                "bluetooth": {
                    "actions": [
                        "TurnOff",
                        "TurnOn"
                    ],
                    "btlist": [
                    ],
                    "connecting": "off",
                    "pairing": "off",
                    "scanlist": [
                    ],
                    "scanning": "off",
                    "state": "on"
                },
                "cellular": {
                    "actions": [
                    ],
                    "state": "off"
                },
                "energySavingMode": {
                    "actions": [
                    ],
                    "state": "off"
                },
                "flashLight": {
                    "actions": [
                        "TurnOff",
                        "TurnOn"
                    ],
                    "state": "off"
                },
                "gps": {
                    "actions": [
                    ],
                    "state": "on"
                },
                "localTime": "2024-01-23T22:47:45+09:00",
                "screenAutoBrightness": {
                    "actions": [
                        "TurnOff",
                        "TurnOn"
                    ],
                    "state": "on"
                },
                "screenBrightness": {
                    "actions": [
                        "Decrease",
                        "Increase",
                        "SetValue"
                    ],
                    "max": 255,
                    "min": 1,
                    "value": 84
                },
                "soundMode": {
                    "actions": [
                        "TurnOff",
                        "TurnOn"
                    ],
                    "state": "silent"
                },
                "volume": {
                    "actions": [
                        "Decrease",
                        "Increase",
                        "SetValue"
                    ],
                    "max": 15,
                    "min": 0,
                    "mute": true,
                    "value": 0
                },
                "wifi": {
                    "actions": [
                        "TurnOff",
                        "TurnOn"
                    ],
                    "networks": [
                        {
                            "connected": true,
                            "name": "\"Buffalo-G-78F0\""
                        }
                    ],
                    "state": "on"
                }
            }
        },
        {
            "header": {
                "namespace": "Clova",
                "name": "Assistant"
            },
            "payload": {
                "voiceType": "V001"
            }
        }
    ],
    "event": {
        "header": {
            "namespace": "ClovaHome",
            "name": "GetGroupTypeInfoListRequest",
            "messageId": "cb442a22-cb7e-473c-8f3d-aa29cad5ea40"
        },
        "payload": {
        }
    }
}
--2b935de8-c205-496b-b494-5f7b42f7223b--

event内の変更で設定可能

    "event": {
        "header": {
            "namespace": "Settings",
            "name": "RequestUpdate",
            "messageId": "65516576-468d-49bb-bd1e-43426bd4aaa6"
        },
        "payload": {
            "deviceId": "3fd945b20c40473d986e14c69e2fb9a6bae10443becbba3450b504c09c735fca",
            "configuration": {
                "AlarmSoundChangeCompleted": "true"
            }
        }

apiドキュメントにあるやつ

https://developers.naver.com/console/clova/client/Develop/References/CIC_API.md#EstablishDownchannel

curl -X GET -H "Host: prod-ni-cic.clova.ai" -H "User-Agent: ClovaApp/Android/3.7.7 (Android 13;motorola edge 20 pro;other=qcom;pkg=com.naver.nozzle;clovasdk=27.2232.706)" -H "Authorization: Bearer 59in5EmmQO2X5ZCWRRsOmA" https://prod-ni-cic.clova.ai/v1/directives

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment