Skip to main content

Third-Party Applications

The use case for this feature is to use HAP as an identity authentication center, with third-party applications created as the entry point from HAP to external applications. The authentication process is based on the OAuth 2.0 protocol.

1. Create Application

Go to Org AdminIntegration3rd-Party Application to create an application (you can also click the bottom left of the homepage to view the list of created applications).

2. Obtain Request Verification Code

Request Example (GET):
{HAP access address}/api/oauth2/authorize?app_key=441139F6ADFA&redirect_uri=http://www.baidu.com&projectid=f0dc6a74-854a-46cb-ab8c-909b7846d34c

Request Parameters:

  • app_key: Application App Key
  • redirect_uri: Application callback address
  • projectid: Organization ID in HAP

3.Obtain Access Token

Request Parameters:

  • app_key: App Key
  • app_secret: App Secret
  • grant_type: Fixed authorization_code
  • code: Request verification code obtained in the previous step
  • redirect_uri: Application callback URL
  • format: json (by default it returns XML format)

Request Example (GET):
{HAP access address}/api/oauth2/access_token?app_key=441139F6ADFA&app_secret=6188275EF965388891B3618BD9398A&grant_type=authorization_code&code=f8a6f0ffb8d249499f4e7c332d2446c4&redirect_uri=http://www.baidu.com&&format=json

Request Result:

{
"access_token": "9h9kapa********",
"expires_in": "604800",
"refresh_token": "00b100b5********",
"success": true
}

4. Obtain Info about Current Account

Request Example (GET):
{HAP access address}/api/v1/passport/get_passport_detail?access_token=9h9kapa********

Request Result (Key Fields):

{
"data": {
"user_id": "string", // User ID, different in different organizations for the same account
"full_name": "string", // Name
"account_id": "string", // Account ID, same in different organizations for the same account
"project_id": "string", // Organization ID
"email": "string", // Email
"mobile_phone": "string", // Phone number
"department": "string", // Department
"job": "string", // Position
"job_number": "string", // Job number
"work_site": "string", // Work location
"contact_phone": "string", // Work phone
},
"success": true,
"error_code": 1
}