@@ -172,6 +172,25 @@ public static string AccountState
172
172
public static string LastName { get ; set ; }
173
173
public static string ProfilePictureSource { get ; set ; }
174
174
175
+ private static IEnumerable < string > DetermineLoginScopes ( )
176
+ {
177
+ List < string > scopes = new List < string > ( ) { "wl.basic" } ;
178
+
179
+ ApplicationDataContainer roamingSettings = ApplicationData . Current . RoamingSettings ;
180
+
181
+ // Check if user has given consent to save data into their SkyDrive storage.
182
+ if ( roamingSettings . Values . ContainsKey ( "saveSkyDrive" ) )
183
+ {
184
+ if ( ( bool ) roamingSettings . Values [ "saveSkyDrive" ] )
185
+ {
186
+ scopes . Add ( "wl.skydrive" ) ;
187
+ scopes . Add ( "wl.skydrive_upload" ) ;
188
+ }
189
+ }
190
+
191
+ return scopes ;
192
+ }
193
+
175
194
/// <summary>
176
195
/// Tries signing in the user with their Microsoft account
177
196
/// </summary>
@@ -199,22 +218,17 @@ public static async Task UpdateUserName(Boolean signIn)
199
218
// has not already given consent to this app to access the data
200
219
// described by the scope.
201
220
202
- List < string > scopes = new List < string > ( ) { "wl.basic" } ;
221
+ List < string > scopes = DetermineLoginScopes ( ) . ToList ( ) ;
203
222
204
- ApplicationDataContainer roamingSettings = ApplicationData . Current . RoamingSettings ;
205
-
206
- // Check if user has given consent to save data into their SkyDrive storage.
207
- if ( roamingSettings . Values . ContainsKey ( "saveSkyDrive" ) )
223
+ // Sign in the user with the given scopes
224
+ try
208
225
{
209
- if ( ( bool ) roamingSettings . Values [ "saveSkyDrive" ] )
210
- {
211
- scopes . Add ( "wl.skydrive" ) ;
212
- scopes . Add ( "wl.skydrive_upload" ) ;
213
- }
226
+ loginResult = await LCAuth . LoginAsync ( scopes ) ;
227
+ }
228
+ catch ( Exception ex )
229
+ {
230
+ string m = ex . Message ;
214
231
}
215
-
216
- // Sign in the user with the given scopes
217
- loginResult = await LCAuth . LoginAsync ( scopes ) ;
218
232
}
219
233
else
220
234
{
0 commit comments