c# - Office365 API OutlookServicesClient hangs when acquiring token -


i following example here: get started office 365 apis

when controller action executes, hangs on following line inside of var "new outlookservicesclient"

var authresult = await authcontext.acquiretokensilentasync(     dcr.serviceresourceid,     new clientcredential(this.configuration.idaclientid, this.configuration.idaclientsecret),     new useridentifier(userobjectid, useridentifiertype.uniqueid)); 

i cannot figure out why hanging, especially, since acquiretokensilentasync works fine in discovery client right before call.

any appreciated.

my controller action method:

[authorize] public async task<actionresult> index() {         var contacts = new list<contactitem>();     var signinuserid = claimsprincipal.current.findfirst(claimtypes.nameidentifier).value;     var userobjectid = claimsprincipal.current.findfirst(claimtypesadditions.objectidentifier).value;      var authcontext = new authenticationcontext(this.configuration.idaauthority, new adaltokencache(signinuserid));      try     {         var discclient = new discoveryclient(             new uri(this.configuration.office365discoveryserviceendpoint),             async () =>             {                 var authresult = await authcontext.acquiretokensilentasync(                     this.configuration.office365discoveryresourceid,                     new clientcredential(this.configuration.idaclientid, this.configuration.idaclientsecret),                     new useridentifier(userobjectid, useridentifiertype.uniqueid));                  return authresult.accesstoken;             });          var dcr = await discclient.discovercapabilityasync("contacts");          var exclient = new outlookservicesclient(             dcr.serviceendpointuri,             async () =>             {                 var authresult = await authcontext.acquiretokensilentasync(                     dcr.serviceresourceid,                     new clientcredential(this.configuration.idaclientid, this.configuration.idaclientsecret),                     new useridentifier(userobjectid, useridentifiertype.uniqueid));                  return authresult.accesstoken;             });          var contactsresult = await exclient.me.contacts.executeasync();                  {             var c = contactsresult.currentpage;             contacts.addrange(c.select(contact => new contactitem { firstname = contact.givenname }));              contactsresult = await contactsresult.getnextpageasync();         }         while (contactsresult != null);     }     catch (adalexception exception)     {         if (exception.errorcode == adalerror.failedtoacquiretokensilently)         {             authcontext.tokencache.clear();         }     }      return this.view("index", contacts); } 

there bug in version of 1.0.34 microsoft.office365.outlookservices.portable causes deadlock in outlookserviceclient. reverting 1.0.22 seems work.

this documented here https://github.com/officedev/o365-aspnetmvc-start/commit/b5652864756636a0b141c222e964aba953357e7a#diff-04c6e90faac2675aa89e2176d2eec7d8r139

and looks fixed in next release seen here https://github.com/microsoft/vipr/commit/aaeff5cb94204c23d7501be8fa74b0260ddc52d9


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -