diff --git a/src/D2L.Bmx/WriteHandler.cs b/src/D2L.Bmx/WriteHandler.cs index d424b03a..de0287dc 100644 --- a/src/D2L.Bmx/WriteHandler.cs +++ b/src/D2L.Bmx/WriteHandler.cs @@ -70,6 +70,13 @@ bool useCredentialProcess if( !data.Sections.ContainsSection( sectionName ) ) { data.Sections.AddSection( sectionName ); } + if( File.Exists( SharedCredentialsFile.DefaultFilePath ) ) { + var defaultCredentialsFile = parser.ReadFile( SharedCredentialsFile.DefaultFilePath ); + if( defaultCredentialsFile.Sections.ContainsSection( profile ) ) { + defaultCredentialsFile.Sections.RemoveSection( profile ); + parser.WriteFile( SharedCredentialsFile.DefaultFilePath, defaultCredentialsFile ); + } + } data[sectionName]["credential_process"] = "bmx print --format json --cache --non-interactive" + $" --org \"{oktaApi.Org}\""