kenakamu / UCWA2.0-CS

C# library for UCWA 2.0
MIT License
24 stars 13 forks source link

Intermittent access denied "page" when trying to create the application #37

Closed baywet closed 6 years ago

baywet commented 6 years ago

Hi @kenakamu We've been running our application in pre-prod for a couple of months now.
Basically it creates skype meetings automatically depending on information entered by users on a form.
We're leveraging a service account + application so the authentication is handled via authContext.AcquireTokenAsync(resource, ApplicationId, userCredential) Approximately every 2 to 5 days we see times ranging from a couple of minutes to a couple of hours were we get these traces in the log of our webjob.

[12/20/2017 14:05:33 > 7d18d5: INFO] <div id="header"><h1>Server Error</h1></div>
[12/20/2017 14:05:33 > 7d18d5: INFO] <div id="content">
[12/20/2017 14:05:33 > 7d18d5: INFO]  <div class="content-container"><fieldset>
[12/20/2017 14:05:33 > 7d18d5: INFO]   <h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
[12/20/2017 14:05:33 > 7d18d5: INFO]   <h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
[12/20/2017 14:05:33 > 7d18d5: INFO]  </fieldset></div>
[12/20/2017 14:05:33 > 7d18d5: INFO] </div>
[12/20/2017 14:05:33 > 7d18d5: INFO] </body>
[12/20/2017 14:05:33 > 7d18d5: INFO] </html>
[12/20/2017 14:05:33 > 7d18d5: INFO] ---
[12/20/2017 14:05:33 > 7d18d5: INFO]    at Microsoft.Skype.UCWA.UCWAClient.<CreateApplication>d__449.MoveNext(

At this point I'm not sure what causes that and how we can prevent it from a SDK perspective. Would you have any idea on the subject?

baywet commented 6 years ago

The issue is probably in GetUserDiscoverUri as CreateApplication rethrows exceptions (bad practice, should be fixed)

baywet commented 6 years ago

Found what the issue was, exceptions were rethrown at some places. Once that was fixed I could find and fix the issue which was a sequence implementation issue from https://ucwa.skype.com/documentation/KeyTasks-CreateApplication as well as an issue with expired tokens. PR has been submitted