Skip to main content

Get An Authorization Code

  • 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

ParameterTypeRequiredDescriptionValues/Example
response_typeStringRequiredAuthorization type : codecode
client_idStringRequiredClientIDCLINETTEST
scopeStringRequiredAuthorization scope
user:user
trade:trade
wr:write read
user:trade:wr
stateStringOptionalUnique String
Returned during the callback, used for tampering verification.
MiLCJjb25uZWN0aW9uX3R5cGUiOiJs
redirect_uriStringRequiredThe callback URL registered by your application during the application process will be called after the user successfully authorizes.http://testcallbackurl.com

Response

ParameterTypeRequiredDescriptionValues/Example
codeStringRequiredAuthorization codeMDM2T0IyUFNRNDk4UzBLSEtCVDgwMDAwMDA=
stateStringOptionalUnique 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