SharepointOnlineCredentials works from Debug and CommandLine but not from External App


  • I have written a C# CSOM Console App to post an engineering doc and it's metadata to SPO.

    It works great from Debug mode and from the Command Line, but does not work when called from a Teamcenter (Tc) workflow.

    The Tc workflow DOES run, the Console App IS called (validating inputs, renaming files, etc.), but fails on a SharepointOnlineCredentials call with the following message:
    The external commend exited with the following error: External Command "...\Push2Seda.exe" returned error code -532462766.

    ADFS authentication was recently implemented, and attempts to bypass it via an etc/hosts update produced no change in behavior.

    My code looks like this:

            // Connect to Sharepoint, Establish client-side context
            using (SP.ClientContext ctx = new SP.ClientContext(sDestSite))
                // Get Credentials
                ctx.Credentials = GetSPOCredentials("username@domain", "password");
                Log(sLogFile, string.Format("Got Credentials"));
            public static SP.SharePointOnlineCredentials GetSPOCredentials(string userName, string password)
                SecureString securePassword = new SecureString();
                foreach (char ch in password) securePassword.AppendChar(ch);
                return new SP.SharePointOnlineCredentials(userName, securePassword);

    This was working before ADFS authentication was implemented...

    Any idea how to solve this problem?



    Monday, July 11, 2016 6:23 PM