Creating OAuth Authorization
Function
This API is used to create OAuth authorization.
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 tag. |
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. |
To obtain the values of code and state, perform the following steps:
- Enter the URL obtained in Obtaining an Authorization Redirection URL in the address box of the browser and press Enter.
- On the login page, enter your code repository account and password.
If you have logged in to the code repository, skip this step.
- On the login page of the console, enter the account name and password, and click Log In.
If you have logged in to the console, skip this step.
- After the system displays a message indicating that the authorization fails to be created, copy the URL in the address box. Example:
https://console****.com/servicestage/oauth?repo_type=github&code=04bed2df009f3fc9***c&state=%242a%2410%24.uQYThj5yKFs51w9s9ajeuQ0NSGshPH7IUfXoZLPlz7J%2FoAJ8B***
- Decode the obtained URL to obtain the decoded URL. Example:
https://console.****.com/servicestage/oauth?repo_type=github&code=04bed2df009f3fc9***c&state=$2a$10$.uQYThj5yKFs51w9s9ajeuQ0NSGshPH7IUfXoZLPlz7J/oAJ8B***
Obtain the values of code and state.
The value of the obtained state is a one-off authentication code and random string, which can be used only once. If you need to call this API again to create OAuth authorization, follow the steps in Obtaining an Authorization Redirection URL again to obtain the URL and obtain the values of code and state.
Response
Response parameters
Parameter |
Type |
Description |
---|---|---|
authorization |
Object |
Authorization structure. 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 |
Update 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
Status Code |
Description |
---|---|
200 |
OK |
400 |
Bad Request |
Error Code
Error code must be in the format of SVCSTG.REPO.[Error_ID]. Example: SVCSTG.REPO.0401. See ServiceStage Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot