Skip to content

Commit 9e0b25b

Browse files
committed
Expose IdToken and AccessToken instead of ActiveToken
1 parent b21167d commit 9e0b25b

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

src/Plugin.GoogleClient/GoogleClientManager.android.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ public void Logout()
173173
if (GoogleSignIn.GetLastSignedInAccount(CurrentActivity)!=null)
174174
{
175175
//Auth.GoogleSignInApi.SignOut(GoogleApiClient);
176-
_activeToken = null;
176+
_idToken = null;
177+
_accessToken = null;
177178
mGoogleSignInClient.SignOut();
178179
//GoogleApiClient.Disconnect();
179180

@@ -197,8 +198,10 @@ public bool IsLoggedIn
197198
}
198199
}
199200

200-
public string ActiveToken { get { return _activeToken; } }
201-
static string _activeToken { get; set; }
201+
public string IdToken { get { return _idToken; } }
202+
public string AccessToken { get { return _accessToken; } }
203+
static string _idToken { get; set; }
204+
static string _accessToken { get; set; }
202205

203206
static EventHandler<GoogleClientErrorEventArgs> _onError;
204207
public event EventHandler<GoogleClientErrorEventArgs> OnError
@@ -231,8 +234,8 @@ private static void OnSignInSuccessful(GoogleSignInAccount userAccount)
231234
Picture = new Uri((userAccount.PhotoUrl != null ? $"{userAccount.PhotoUrl}" : $"https://autisticdating.net/imgs/profile-placeholder.jpg"))
232235
};
233236

234-
_activeToken = userAccount.IdToken;
235-
System.Console.WriteLine($"Active Token: {_activeToken}");
237+
_idToken = userAccount.IdToken;
238+
System.Console.WriteLine($"Id Token: {_idToken}");
236239

237240

238241
if (userAccount.GrantedScopes != null && userAccount.GrantedScopes.Count>0)
@@ -246,9 +249,9 @@ private static void OnSignInSuccessful(GoogleSignInAccount userAccount)
246249

247250
System.Console.WriteLine($"Scopes: {scopes}");
248251

249-
var accessToken = GoogleAuthUtil.GetToken(Application.Context, userAccount.Account, scopes);
252+
_accessToken = GoogleAuthUtil.GetToken(Application.Context, userAccount.Account, scopes);
250253

251-
System.Console.WriteLine($"Access Token: {accessToken}");
254+
System.Console.WriteLine($"Access Token: {_accessToken}");
252255
}
253256
catch (Exception ex)
254257
{

src/Plugin.GoogleClient/GoogleClientManager.apple.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ public class GoogleClientManager : NSObject, IGoogleClientManager, ISignInDelega
1919
// Class Debug Tag
2020
private String Tag = typeof(GoogleClientManager).FullName;
2121

22-
public string ActiveToken { get { return _activeToken; } }
23-
string _activeToken { get; set; }
22+
public string IdToken { get { return _idToken; } }
23+
public string AccessToken { get { return _accessToken; } }
24+
static string _idToken { get; set; }
25+
static string _accessToken { get; set; }
2426
static string _clientId { get; set; }
2527

2628
public GoogleUser CurrentUser
@@ -134,8 +136,10 @@ public async Task<GoogleResponse<GoogleUser>> LoginAsync()
134136
{
135137
if (error == null)
136138
{
137-
_activeToken = authentication.AccessToken;
138-
System.Console.WriteLine($"Active Token: {_activeToken}");
139+
_accessToken = authentication.AccessToken;
140+
_idToken = authentication.IdToken;
141+
System.Console.WriteLine($"Id Token: {_idToken}");
142+
System.Console.WriteLine($"Access Token: {_accessToken}");
139143
}
140144

141145
});
@@ -214,7 +218,8 @@ public void Logout()
214218

215219
if (IsLoggedIn)
216220
{
217-
_activeToken = null;
221+
_idToken = null;
222+
_accessToken = null;
218223
SignIn.SharedInstance.SignOutUser();
219224
// Send the logout result to the receivers
220225
OnLogoutCompleted(EventArgs.Empty);
@@ -323,8 +328,10 @@ private void OnSignInSuccessful(Google.SignIn.GoogleUser user)
323328
{
324329
if(error ==null)
325330
{
326-
_activeToken = authentication.AccessToken;
327-
System.Console.WriteLine($"Active Token: {_activeToken}");
331+
_accessToken = authentication.AccessToken;
332+
_idToken = authentication.IdToken;
333+
System.Console.WriteLine($"Id Token: {_idToken}");
334+
System.Console.WriteLine($"Access Token: {_accessToken}");
328335
}
329336

330337
});

src/Plugin.GoogleClient/IGoogleClientManager.shared.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public interface IGoogleClientManager
8080
Task<GoogleResponse<GoogleUser>> LoginAsync();
8181
Task<GoogleResponse<GoogleUser>> SilentLoginAsync();
8282
void Logout();
83-
string ActiveToken { get; }
83+
string IdToken { get; }
84+
string AccessToken { get; }
8485
GoogleUser CurrentUser { get; }
8586
bool IsLoggedIn { get; }
8687
//DateTime TokenExpirationDate { get; }

0 commit comments

Comments
 (0)