...
Acquire the Authentication ID – To begin the process, invoke the
ui/common/ModernAuth/GetModernAuthID
REST endpoint to obtain the Authentication ID. The C# code snippet below illustrates this step:Code Block language c# private static string GetID() { var web = new WebClient(); var urla = $"https://my.empoweriempowerid/ui/common/ModernAuth/GetModernAuthID"; var responseString = web.DownloadString(urla); return responseString; }
Perform Authentication – Launch a browser or a browser tab and direct it to the '/PerformAuth' endpoint. Provide the Authentication ID acquired in the first step ('{sid}') and the Client ID of the OAuth application ('{clientId}') as parameters. The URL should look similar to that shown below.
https://my.empowerid/ui/common/ModernAuth/PerformAuth/?sid={sid}&client_id={clientId}
Insert excerpt IL:Callouts IL:Callouts name ModernAuthSuccess nopanel true Obtain the Access Token – Invoke the
/ui/common/ModernAuth/GetAccessToken/
REST endpoint using the Authentication ID acquired in the first step ('{sid}'). If the endpoint returns an empty response, the access token is not available. You can repeatedly call this endpoint with the Authentication ID at intervals of 10 to 15 seconds for a minute or two before determining that the authentication has failed. The C# code snippet below illustrates this step:Code Block language c# private static string GetToken() { var web = new WebClient(); var urla = $"https://my.empoweriempowerid/ui/common/ModernAuth/GetAccessToken/{sid}"; var responseString = web.DownloadString(urla); if(!string.IsNullOrEmpty(responseString)) { var data = JsonConvert.DeserializeObject<DataClass>(responseString); return data.AccessToken } return null; } public class DataClass { public string AccessToken {get; set;} public string {get; set;} }
...