GetOAuthTokenResult GetOAuthToken(GetOAuthTokenArg tArg)
tArg. Operation execution parameters.
The GetOAuthToken operation gets tokens from external service.
Before executing the GetOAuthToken operation it is assumed that the GetOAuthSettings and CreateOAuthState operations were already executed, the user was authenticated in external service, and results of these operations are available.
To execute the GetOAuthToken operation, in the tArg.svcKey field specify the previously used authentication service key, and in the tArg.applicationUrl field specify path to the web application root that will be used as address for returning to the application, the value should be equal to the previously specified value in CreateOAuthState.tArg.redirectUri. In the tArg.loginCode and tArg.state fields specify values of the obtained code and state parameters.
During the request execution the BI server checks value of parameter for protection against potential CSRF attacks during authorization code request. In case of successful check, the system opens the external service to get tokens. The BI server returns key for using tokens. This key will be available in the oauth_token field as a result of operation execution and can be sent to the OpenMetabase operation.
Below is the example of getting tokens from external service. It is assumed that all required operations are already executed and their results are obtained. The request contains URL of the page, to which the user is redirected after authentication, the code obtained during authentication, authentication service settings key, and the code generated by BI server for checking request authenticity. The response contains key for using tokens.
{
"GetOAuthToken" :
{
"tArg" :
{
"applicationUrl" : "https:\/\/myserver.com\/FP_App_v10.x\/r\/#\/redirect",
"loginCode" : "g0ZGZmNjVmOWI",
"svcKey" : "0",
"state" : "ED9F5DF6E55440CDA86561A87A71CD33"
}
}
}
{
"GetOAuthTokenResult" :
{
"oauth_token" : "g0ZGZmNjVmOWI"
}
}
public static GetOAuthTokenResult GetOAuthToken(string url, string code, uint key, string checkState)
{
var somClient = new SomPortTypeClient(); // Proxy object for operation execution
// Operation execution parameters
var tGet = new GetOAuthToken()
{
tArg = new GetOAuthTokenArg()
{
applicationUrl = url,
loginCode = code,
svcKey = key,
state = checkState
}
};
// Get token
var result = somClient.GetOAuthToken(tGet);
return result;
}
See also: