Get An Authorization Code
Redirect Link Description
-
Function description:
This is the first step of the OAuth process. An authorization code is created when the user authorizes your application to access their account. If the user grants permission to your application, the callback URL registered in your application will be invoked. The interface for obtaining the authorization code is completed in the browser.
-
Request Method:Browser requests the redirect link
-
Request URL:/oauth2/authenticate/login
Parameters
| Parameter | Type | Required | Description | Values/Example |
|---|---|---|---|---|
| response_type | String | Required | Authorization type : code | code |
| client_id | String | Required | ClientID | CLINETTEST |
| scope | String | Required | Authorization scope user:user trade:trade wr:write read | user:trade:wr |
| state | String | Optional | Unique String Returned during the callback, used for tampering verification. | MiLCJjb25uZWN0aW9uX3R5cGUiOiJs |
| redirect_uri | String | Required | The callback URL registered by your application during the application process will be called after the user successfully authorizes. | http://testcallbackurl.com |
Response
| Parameter | Type | Required | Description | Values/Example |
|---|---|---|---|---|
| code | String | Required | Authorization code | MDM2T0IyUFNRNDk4UzBLSEtCVDgwMDAwMDA= |
| state | String | Optional | Unique string during the request. This is returned for tampering verification; if it is provided during the request, it will also be returned in the response. | MiLCJjb25uZWN0aW9uX3R5cGUiOiJs |
Code Example
Open the authorization page in the browser (using the UAT environment as an example):
https://passport.uat.webullbroker.com/oauth2/authenticate/login?response_type=code&client_id=CLINETTEST&scope=user:trade:wr&redirect_uri=http://testcallbackurl.com&state=MiLCJjb25uZWN0aW9uX3R5cGUiOiJs
Response
After successful authorization, it will call back to the redirect_uri in the request parameters, structured as follows:
http://testcallbackurl.com?code=MDM2T0IyUFNRNDk4UzBLSEtCVDgwMDAwMDA=&state=MiLCJjb25uZWN0aW9uX3R5cGUiOiJs