1

I am trying to integrate Login flow with oidc-client in Office JS excel add-in and below are the findings.

  1. I could able to integrate as attached below code flow but in that i am getting some issue as attached in screen shot.
  2. Kindly review the below latest code and suggest what i am missing.
  3. Attached kind of CORS issue was not getting when tried with another library(office-js-helpers)with same end point parameters.

PFB updated latest code:

auth.ts

Office.initialize = function () {

    var settings = {
      authority: "https://xxxxxx.com/xxxx/xx",      
      client_id: "https://xxxxxxx.com/",
      redirect_uri: "https://localhost:3000/taskpane.html",
      // silent_redirect_uri:"https://localhost:3000/taskpane.html", 
      post_logout_redirect_uri: "https://xxxxxxx.com/",       
      response_type: "id_token token",
      scope: "openid read:xxxx read:xxxxxx read:xxxxxxx",
      state: true,
      clearHashAfterLogin: false,
      filterProtocolClaims: true,  
      loadUserInfo: true,
      nonce:true,       
    };
    Oidc.Log.logger = console;
    var mgr = new Oidc.UserManager(settings); 
    mgr.signinRedirect();
    mgr.signinRedirectCallback().then((user) => {       
      if (user) {
        console.log(user);

      } else {
        mgr.signinPopupCallback().then(function (user) {
          window.location.href = '../';
        }).catch(function (err) {
          console.log(err);
        });
        throw new Error('user is not logged in');
      }
    });    
  };

taskpane.ts

const loginpopup = function () {
      if (OfficeHelpers.Authenticator.isAuthDialog())
        return;     
      Office.context.ui.displayDialogAsync(
        url,
        { height: 60, width: 60, /*displayInIframe:true*/ },
        dialogCallback);
      function dialogCallback(asyncResult) {
        if (asyncResult.status == "failed") {
         
          switch (asyncResult.error.code) {
            case 12004:
              console.log("Domain is not trusted");
              break;
            case 12005:
              console.log("HTTPS is required");
              break;
            case 12007:
              console.log("A dialog is already opened.");
              break;
            default:
              console.log(asyncResult.error.message);
              break;
          }
        }
        else {
          dialog = asyncResult.value; 
          dialog.addEventHandler(Office.EventType.DialogMessageReceived, messageHandler);
        }
      }
      function messageHandler(arg: any) {
        if (arg != "jsonMessage") {
          $(".loader").show();
          var test = JSON.parse(arg.message).value.split("#")[1].split("&")[1].split("=");         
          dialog.close();
        };
      }
}
chennaiyan
  • 69
  • 1
  • 6
  • Try changing the `redirect_uri` to `"https://localhost:3000/auth.html"`. – Rick Kirkham Jun 15 '20 at 17:55
  • @rick... That also I already tried but same issue...please confirm anything other check need to do – chennaiyan Jun 16 '20 at 03:19
  • Hi team, I have updated my workaround kindly help on the same.. – chennaiyan Jun 16 '20 at 13:41
  • @oidc-client team...can you please help ASAP since we are in middle of integrating this library in officejs and could not able to proceed further.... – chennaiyan Jun 16 '20 at 17:23
  • Hi team... Any help on this – chennaiyan Jun 17 '20 at 12:51
  • Hi Team, I have tried with some work around and came across updated issue...Can you please help on this? – chennaiyan Jun 18 '20 at 12:07
  • Hi Team,,,are any of team looking into this?...kindly confirm.. – chennaiyan Jun 19 '20 at 09:48
  • I would recommend that you put aside the Office add-in for now. Try to get a simple web application working with oidc-client and your custom auth server. If you encounter any problems, ask a Stack question and tag it `odic-client`, but do not tag it `office-js`. Once you've got that working, you can try to apply the code to your Office add-in. – Rick Kirkham Jun 19 '20 at 17:45
  • @RickKirkham...As per attached latest code I was able to get access token in taskpane.ts file as args in messageHandler...But when i logged in fresh browser that time only Secure Token Service (STS) login window getting opening. If i logged out and cleared access token then again trying to logged in that time directly getting in as logged user without opening Secure Token Service (STS) window. Once i cleared browser cache and all then only i am able to get Secure Token Service (STS) window again... Can you please advise about the scenario to handle? – chennaiyan Jun 24 '20 at 17:25

0 Answers0