
# 设备鉴权
#### 流程说明
图1设备鉴权流程图   
![](https://support.huaweicloud.com/api-iothub/figure/zh-cn_image_0000002069333441.png)
#### LwM2M对象资源
设备向物联网平台注册，物联网平台进行设备的身份认证。
| Operation | CoAP Method | URI                                                                                              | Success      | Failure                                                                                                                                                                                                        |
|:---|:---|:---|:---|:---|
| Register  | POST        | /rd?ep={nodeId}  | 2.01 Created | 4.00 Bad Request, 4.03 Forbidden, 4.12 Precondition Failed |
   
物联网平台向设备订阅资源，设备获取到物联网平台下发订阅时的token，调用属性上报等其他接口时，都需要携带token信息。
| Operation | CoAP Method                 | URI     | Success                          | Failure                                                                                                                                                                                                                                                                                                         |
|:---|:---|:---|:---|:---|
| Observe   | GET with Observe option = 0 | /19/0/0 | 2.04 Content with Observe option | 4.00 Bad Request, 4.04 Not Found, 4.01 Unauthorized, 4.05 Method Not Allowed |
   
#### 请求参数
| 名称     | 必选 | 类型     | 位置        | 说明                                         |
|:---|:---|:---|:---|:---|
| nodeId | 是  | String | Uri-Query | **参数说明:**设备标识码，用于唯一标识一个设备。在物联网平台注册设备时直接指定。 |
   
#### Register请求示例
```
CON-POST   MID=25995, Token=514078a73366, OptionSet={"Uri-Path":"rd", "Content-Format":"application/octet-stream", "Uri-Query":["ep=test"]}
```
#### Register响应示例
```
ACK-2.01   MID=25995, Token=514078a73366, OptionSet={"Location-Path":["rd","test"]}, no payload：
```
#### Observe请求示例
```
CON-GET    MID=48590, Token=2cb6a673cba24c04, OptionSet={"Observe":0, "Uri-Path":["19","0","0"], "Accept":"application/octet-stream"}, no payload
```
#### Observe响应示例
```
ACK-2.04   MID=48590, Token=2cb6a673cba24c04, OptionSet={"Observe":0, "Content-Format":"application/octet-stream"}
```
