4 Replies Latest reply on Jul 6, 2018 10:15 AM by R Beeler

    tableau.abortForAuth() does not launch WDC with custom auth

    Sean O'Brien

      I have a WDC which uses custom auth.  On the WDC page, the user enters credentials, which authenticate and return a token.  I'm storing this token in tableau.password.  All works well until the token expires.  When it expires, my connector properly detects this during an extract refresh and is calling tableau.abortForAuth().

       

      However, this only triggers an error message with the string passed into abortWithAuth().  It does not launch the connector page again which would allow re-authentication.  The only workaround I can find is to go to the data source and hit "Edit Connection" which launches the connector in the interactive phase.

       

      Per this page in the tutorial, it seems like it should be launching the connector again (albeit in an auth phase, where I can only modify tableau.username and tableau.password).

       

      In that case, if the user wishes to refresh the extract, re-authentication needs to happen first. When the user tries to refresh the data source, one of three things can happen depending on the value of authType.

      • If authType is none, then nothing will happen.
      • If authType is basic, Tableau will show a standard username/password dialog.
      • If authType is custom, Tableau will launch the web data connector in a special Auth Phase (see the following section).

       

      The auth phase will be displayed by Tableau in two scenarios:

      • The WDC uses authType custom, the current user is un-authenticated (as described above, when opening an existing workbook), and the user attempts to refresh the extract or edit the connection.
      • The WDC developer calls tableau.abortForAuth.
        • 1. Re: tableau.abortForAuth() does not launch WDC with custom auth
          Brendan Lee

          Hey Sean,

           

          Thanks for bringing this up.  Where are you calling abortForAuth from? Looking into this I realize we have a docs error.  The docs say abortForAuth only has function during the gather data phase, but in fact, it's more restrictive than that.  This function only works properly when called during the init method of our gather data phase.    I will get the docs updated.

           

          If that isn't the issue, it might be a bug on our end.  What version of Tableau / WDC API are you using?

           

          Thanks,

          Brendan

          • 2. Re: tableau.abortForAuth() does not launch WDC with custom auth
            Sean O'Brien

            That appears to be my initial problem.  I was calling tableau.abortForAuth() from the getData() function.  I've now moved that to the init function as you described.  Init will test the token if the phase is gatherData and abortForAuth() if it is invalid.

             

            Under this new setup, when the token expires, I receive a pop up stating "Invalid username or password for data source.  Would you like to edit the connection information?"   Clicking 'Yes' to this dialog, does not launch the connector UI though.  It gives me another error which says "An error occurred while communicating with the data source."  Under details it says "Missing Password" and then aborts the extract refresh.

             

            Looking through the logs, It appears that after tableau.abortForAuth() is called, the init function is called again and the phase is still gatherData.  The UI for the connector is never launched and the phase is never reported to be authPhase.

             

            I'm using WDC version 2.0.9 and Tableau version 10.0.2.  Below is my init function:

             

              connector.init = function(initCallback) {
                tableau.authType = tableau.authTypeEnum.custom;
            
            
                console.log('Phase is: ' + tableau.phase);
                if (tableau.phase == tableau.phaseEnum.gatherDataPhase) {
                  $.ajax({
                    type: 'GET',
                    url: '/v1/validateToken',
                    headers: { 'x-access-token': tableau.password },
                    statusCode: {
                      401: function onUnauthorized(jqXHR, textStatus, errorThrown) {
                        tableau.abortForAuth(textStatus + ": " + errorThrown);
                      }
                    },
                    success: function onSuccess(resp) {
                      initCallback();
                    }
                  });
                }
                else {
                  initCallback();
                }
              }
            
            • 3. Re: tableau.abortForAuth() does not launch WDC with custom auth
              Brendan Lee

              Hey Sean,


              Sorry for the late reply; I asked one the engineers on the team to take a look at this and he thinks it's possibly a bug.  The team is going to investigate further and see if we can reproduce it on our end with those versions.  I will let you know what we discover. 

               

              Thanks for letting us know about this.

               

              -Brendan

              • 4. Re: tableau.abortForAuth() does not launch WDC with custom auth
                R Beeler

                I have re-worked similar code a couple of different ways and see this exact error. Right now, the only way for me to refresh an extract is to close tableau and re-load. I've been unsuccessful in getting the UI to appear more than once. Do you know if there has been any movement for this issue? This is an old post.