Hi @hao chen Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.
Based on the details you have provided on the thread, it looks like you may have missed granting access to the DPS instance to authorize with IoT Hub. This may be the reason you are seeing the unauthorized error. Could you please revalidate if your DPS instance has enough permissions on the IoT Hub where you are trying to provision your device. Please refer the below image for reference.
Please also refer the following resources that will help you guide through the steps needed to use the SDK and provision a device.
- Quickstart: Set up the IoT Hub Device Provisioning Service with the Azure portal
- Quickstart: Provision a simulated symmetric key device
Kindly let us know if you still experience any issues after following the steps from the above articles.
If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.