Skip to content

Commit 123e91f

Browse files
authored
Update GoogleClientManager.android.cs
1 parent 52a3ecf commit 123e91f

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Plugin.GoogleClient/GoogleClientManager.android.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,22 @@ void OnSignInSuccessful(GoogleSignInAccount userAccount)
241241
if (userAccount.GrantedScopes != null && userAccount.GrantedScopes.Count>0)
242242
{
243243
var scopes = $"oauth2:{string.Join(' ', userAccount.GrantedScopes.Select(s => s.ScopeUri).ToArray())}";
244-
245-
_accessToken = GoogleAuthUtil.GetToken(Application.Context, userAccount.Account, scopes);
244+
System.Console.WriteLine($"Scopes: {scopes}");
245+
var tcs = new TaskCompletionSource<string>();
246+
Task.Run(() =>
247+
{
248+
try
249+
{
250+
tcs.TrySetResult(GoogleAuthUtil.GetToken(Application.Context, userAccount.Account, scopes));
251+
}
252+
catch (Exception ex)
253+
{
254+
tcs.TrySetResult(string.Empty);
255+
System.Console.WriteLine($"Ex: {ex}");
256+
}
257+
});
258+
259+
_accessToken = await tcs.Task;
246260

247261
System.Console.WriteLine($"Access Token: {_accessToken}");
248262
}

0 commit comments

Comments
 (0)