trouble validating user identity token

I am following the sample on https://developer.blackbaud.com/skyapi/docs/addins/concepts/addin-sso


When I copy the code at the bottom of the page into my solution, I have to make a couple changes to get it to compile. This is what I come up with:

public async Task<UserIdentityToken> ValidateSingleSignOnToken(string rawToken)
{
// this represents the user identity token returned from getUserIdentityToken()
// var rawToken = "(raw token value)";

// this is the ID of the developer's SKY application
Guid applicationId = new Guid("(removed for post)");

// create and validate the user identity token
UserIdentityToken uit;
try {
uit = await UserIdentityToken.ParseAsync(rawToken, applicationId);

// if valid, the UserId property contains the Blackbaud user's ID
var userId = uit.UserId;

// if valid, the EnvironmentId property contains the environment ID
var envId = uit.EnvironmentId;

return uit;
}
catch (TokenValidationException ex) {
// process the exception
return null;
}
}
When I test this code, it hangs forever on this line:
uit = await UserIdentityToken.ParseAsync(rawToken, applicationId);


I have downloaded the sample solution from https://github.com/blackbaud/addin-tokenauthentication


I am able to run the test app. I can enter a token it validates it successfully.


My project is an ASP.NET Web API. My code seems to be doing basically the same thing, however, mine hangs on that line when I test it.


Any help?

 

Comments

  • Blackbaud who can take a look at this question for us? We are trying to build SKY Add-Ins and this is one of our roadblocks. Any assistance would be greatly appreciated! 
  • Did either of you find a solution to this issue?


    I'm running into it now too. Thanks!
  • OK, I did some more digging and if your issue is like mine, I think it's due to a bug in the Blackbaud.Addin.TokenAuthentication library.


    In my project I'm calling the code from a non-async method and so calling GetAwaiter().GetResult() to block until the token gets parsed. But the library code didn't have any calls to ConfigureAwait(false), so if it gets called from somewhere with limited concurrent operations you can get a deadlock (more info here: https://devblogs.microsoft.com/dotnet/configureawait-faq/).


    I've created a PR that fixes the deadlock in my application: https://github.com/blackbaud/addin-tokenauthentication/pull/13


    If someone from Blackbaud could review that would be great!
  • Following up on this thread, I see that Matthew's PR has been merged (thanks for the contribution!). Jeff, if pulling in the latest version of the library doesn't fix your problem please let us know.

Categories