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",
"full_name": "string",
"account_id": "string",
"project_id": "string",
"email": "string",
"mobile_phone": "string",
"department": "string",
"job": "string",
"job_number": "string",
"work_site": "string",
"contact_phone": "string"
},
"success": true,
"error_code": 1
}

Field Descriptions:

FieldMeaning
user_idUser ID; the same account has different values in different organizations
full_nameName
account_idAccount ID; the same account has the same value in different organizations
project_idOrganization ID
emailEmail
mobile_phonePhone number
departmentDepartment
jobPosition
job_numberJob number
work_siteWork location
contact_phoneWork phone