dlmelendez / identityazuretable

This project provides a high performance cloud solution for ASP.NET Identity Core using Azure Table storage replacing the Entity Framework / MSSQL provider.
MIT License
104 stars 27 forks source link

External login tokens are not saved. #71

Closed Rambalac closed 3 years ago

Rambalac commented 3 years ago

I'm trying to add login through Google to access some Google APIs but I cannot get Google Bearer token after login and it's not saved anywhere in the Storage. I do see Bearer token in OnCreatingTicket but I cannot find its content anywhere after. Am I missing anything?

services.AddAuthentication()
                .AddGoogle(options =>
            {
                IConfigurationSection googleAuthNSection = Configuration.GetSection("Authentication:Google");

                options.ClientId = googleAuthNSection["ClientId"];
                options.ClientSecret = googleAuthNSection["ClientSecret"];
                options.Scope.Add(YouTubeService.Scope.Youtube);
                options.SaveTokens = true;
                options.Events.OnCreatingTicket = ctx =>
                {
                    List<AuthenticationToken> tokens = ctx.Properties.GetTokens().ToList();

                    tokens.Add(new AuthenticationToken()
                    {
                        Name = "TicketCreated",
                        Value = DateTime.UtcNow.ToString()
                    });

                    ctx.Properties.StoreTokens(tokens);

                    return Task.CompletedTask;
                };
            });
dlmelendez commented 3 years ago

I would start with a working new project with the storage provider setup. You can find the dotnet new template instructions here https://dlmelendez.github.io/identityazuretable/#/walkthroughcore5. Once you confirm the login info is being stored in Azure storage, add your google provider information (which seems to be working) more info here https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins?view=aspnetcore-5.0

dlmelendez commented 3 years ago

Closed for lack of activity.