CreateOAuthStateResult CreateOAuthState(CreateOAuthStateArg tArg)
tArg. Operation execution parameters.
The CreateOAuthState operation gets authentication service URL, by which user authentication request will be executed.
To execute the operation, in the tArg.svcKey field specify authentication service key, and in the tArg.redirectUri field specify the path to web application root, which will be used as an address to return to the application after entering user credentials in external service. The authentication service key can be obtained on using the GetOAuthSettings operation.
The operation results in the authentication service address that is specified in service settings in the registry/settings.xml file in the AuthUrl field, which is appended with the return address from tArg.redirectUri, and the generated state parameter for protection against potential CSRF attacks during authorization code request. For details see the Setting Up Authentication via External Services section.
The user should be redirected at the obtained address to enter credentials. If authentication was successful, the external service redirects back to the web application at the address that was specified in the tArg.redirectUri field with specifying the code and state parameters.
Below is the example of getting external authentication service address. The request contains authentication service key and path to the web application, at which the user is returned. The response contains the generated URL.
{
"CreateOAuthState" :
{
"tArg" :
{
"svcKey" : "0",
"redirectUri" : "https:\/\/myserver.com\/FP_App_v10.x\/r\/#\/redirect"
}
}
}
{
"CreateOAuthStateResult" :
{
"authUrl" : "https://accounts.google.com/o/oauth2/auth/authorize?client_id=214433571309-nl9btulcqc3u05d8128uaei3fjrdni8r.apps.googleusercontent.com&response_type=code&access_type=offline&scope=https%3A//www.googleapis.com/auth/userinfo.profile&response_mode=query&redirect_uri=https://myserver.com/FP_App_v10.x/r/#/redirect&state=F52991C98C3F4543992414C9B89CD19A"
}
}
public static CreateOAuthStateResult CreateOAuthState(uint key, string redirect)
{
var somClient = new SomPortTypeClient(); // Proxy object for operation execution
// Operation execution parameters
var tCreate = new CreateOAuthState()
{
tArg = new CreateOAuthStateArg()
{
svcKey = key,
redirectUri = redirect
}
};
// Get authentication service address
var result = somClient.CreateOAuthState(tCreate);
return result;
}
See also: