public static string GetAccessTokenForCpmApi()

in SampleCPMProject/CpmClient/AadAuthentication.cs [19:40]


        public static string GetAccessTokenForCpmApi()
        {
            byte retryCounter = 0;
            AuthenticationResult authenticationResult = null;
            do
            {
                try
                {
                    authenticationResult = context.AcquireTokenAsync(ConfigurationManager.AppSettings["AppResourceId"], credentials).Result;
                }
                catch (AdalException e)
                {
                    retryCounter++;
                    if (retryCounter == 3)
                    {
                        throw e;            //After 3 retries fail the operation.Exception would get logged by middleware.
                    }
                }
            } while (authenticationResult == null);

            return authenticationResult.AccessToken;
        }