Creating OAuth Authorization
Function
This API is used to create OAuth authorization for a Git repository.
URI
POST /v1/{project_id}/git/auths/{repo_type}/oauth
Table 1 describes the parameters.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| project_id | String | Yes | Tenant's project ID. |
| repo_type | String | Yes | Repository type. Value: github, gitlab, gitee, or bitbucket. |
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| tag | String | No | Site label. Example: ?tag=intl, which indicates an international site. |
Request
Request parameters
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
| name | String | Yes | Authorization name. |
| code | String | Yes | Query parameter in the redirection URL after Git repository authorization is performed. |
| state | String | Yes | One-off authentication code and random string received after Git repository authorization is performed. |
Response
Response parameters
| Parameter | Type | Description |
|---|---|---|
| authorization | Object | Authorization struct. For details, see Table 5. |
| Parameter | Type | Description |
|---|---|---|
| name | String | Authorization name. |
| repo_type | String | Repository type. Value: github, gitlab, gitee, or bitbucket. |
| repo_host | String | Repository address. |
| repo_home | String | Repository homepage. |
| repo_user | String | Repository username. |
| avartar | String | Avatar. |
| token_type | String | Authorization mode. |
| create_time | Long | Creation time. |
| update_time | Long | Modification time. |
| status | Integer | Status. |
Example
Example request
{
"name": "string",
"code": "string",
"state": "string"
} Example response
{
"authorization": {
"name": "string",
"repo_type": "string",
"repo_host": "string",
"repo_home": "string",
"repo_user": "string",
"avartar": "string",
"token_type": "string",
"create_time": 0,
"update_time": 0,
"status": 0
}
} Status Code
| HTTP Status Code | Description |
|---|---|
| 200 | OK |
| 400 | Bad Request |
Error code must be in the format of SVCSTG.REPO.[Error_ID]. Example: SVCSTG.REPO.0401. See ServiceStage Error Codes.
Last Article: Obtaining an Authorization Redirection URL
Next Article: Creating Private Token Authorization
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.