@@ -114,30 +114,34 @@ public ConnectorClientFactory(IAddress address, MicrosoftAppCredentials credenti
114
114
115
115
if ( ! oauthClients . TryGetValue ( key , out oauthClient ) )
116
116
{
117
- if ( IsEmulator ( this . address ) && emulateOAuthCards . Value )
117
+ // only create the oauthclient if we have credentials
118
+ if ( ! String . IsNullOrEmpty ( credentials ? . MicrosoftAppId ) && ! String . IsNullOrEmpty ( credentials ? . MicrosoftAppPassword ) )
118
119
{
119
- // for emulator using emulated OAuthCards we should use serviceUri of the emulator
120
- oauthClient = new OAuthClient ( this . serviceUri , this . credentials ) ;
121
- }
122
- else
123
- {
124
- if ( ! string . IsNullOrEmpty ( settingsOAuthApiUrl . Value ) )
120
+ if ( IsEmulator ( this . address ) && emulateOAuthCards . Value )
125
121
{
126
- oauthClient = new OAuthClient ( new Uri ( settingsOAuthApiUrl . Value ) , this . credentials ) ;
122
+ // for emulator using emulated OAuthCards we should use serviceUri of the emulator
123
+ oauthClient = new OAuthClient ( this . serviceUri , this . credentials ) ;
127
124
}
128
125
else
129
126
{
130
- oauthClient = new OAuthClient ( this . credentials ) ;
127
+ if ( ! string . IsNullOrEmpty ( settingsOAuthApiUrl . Value ) )
128
+ {
129
+ oauthClient = new OAuthClient ( new Uri ( settingsOAuthApiUrl . Value ) , this . credentials ) ;
130
+ }
131
+ else
132
+ {
133
+ oauthClient = new OAuthClient ( this . credentials ) ;
134
+ }
131
135
}
132
- }
133
136
134
- if ( IsEmulator ( this . address ) )
135
- {
136
- // Send the mode notification (emulated OAuthCards or not) to the emulator
137
- Task . Run ( async ( ) => await oauthClient . OAuthApi . SendEmulateOAuthCardsAsync ( emulateOAuthCards . Value ) . ConfigureAwait ( false ) ) . Wait ( ) ;
138
- }
137
+ if ( IsEmulator ( this . address ) )
138
+ {
139
+ // Send the mode notification (emulated OAuthCards or not) to the emulator
140
+ Task . Run ( async ( ) => await oauthClient . OAuthApi . SendEmulateOAuthCardsAsync ( emulateOAuthCards . Value ) . ConfigureAwait ( false ) ) . Wait ( ) ;
141
+ }
139
142
140
- oauthClients [ key ] = oauthClient ;
143
+ oauthClients [ key ] = oauthClient ;
144
+ }
141
145
}
142
146
}
143
147
@@ -207,7 +211,7 @@ private static bool GetEmulateOAuthCardsSetting(string key = "EmulateOAuthCards"
207
211
// default back to false
208
212
result = false ;
209
213
}
210
-
214
+
211
215
return result ;
212
216
}
213
217
}
0 commit comments