protected override void LoadUserAuthInfo(AuthUserSession userSession, IAuthTokens tokens, Dictionary <string, string> authInfo) { try { tokens.UserId = authInfo.Get("id"); tokens.UserName = authInfo.Get("email") ?? authInfo.Get("id") ?? authInfo.Get("username"); tokens.DisplayName = authInfo.Get("name"); tokens.FirstName = authInfo.Get("given_name"); tokens.LastName = authInfo.Get("family_name"); tokens.Email = authInfo.Get("email"); var json = AuthHttpGateway.DownloadGoogleUserInfo(tokens.AccessTokenSecret); var obj = (Dictionary <string, object>)JSON.parse(json); if (obj.TryGetValue("picture", out var oProfileUrl) && oProfileUrl is string profileUrl) { tokens.Items[AuthMetadataProvider.ProfileUrlKey] = profileUrl.SanitizeOAuthUrl(); } } catch (Exception ex) { Log.Error($"Could not retrieve google user info for '{tokens.DisplayName}'", ex); } LoadUserOAuthProvider(userSession, tokens); }
protected virtual object AuthenticateWithAccessToken(IServiceBase authService, IAuthSession session, IAuthTokens tokens, string accessToken) { tokens.AccessTokenSecret = accessToken; var json = AuthHttpGateway.DownloadGoogleUserInfo(accessToken); var authInfo = JsonObject.Parse(json); session.IsAuthenticated = true; return(OnAuthenticated(authService, session, tokens, authInfo)); }