diff --git a/src/Owin.Security.Providers.VKontakte/VKontakteAuthenticationHandler.cs b/src/Owin.Security.Providers.VKontakte/VKontakteAuthenticationHandler.cs index 8e4b418..06bb6c4 100644 --- a/src/Owin.Security.Providers.VKontakte/VKontakteAuthenticationHandler.cs +++ b/src/Owin.Security.Providers.VKontakte/VKontakteAuthenticationHandler.cs @@ -95,10 +95,12 @@ namespace Owin.Security.Providers.VKontakte var user = await GetUser(response, accessToken); var context = CreateAuthenticatedContext(user, accessToken, properties); - - // Email support. VK send it with access_token - context.Identity.AddClaim(new Claim(ClaimTypes.Email, response["email"].ToString(), XmlSchemaString, - Options.AuthenticationType)); + var email = response["email"]?.ToString(); + if(!string.IsNullOrWhiteSpace(email)) + { + // Email support. VK send it with access_token + context.Identity.AddClaim(new Claim(ClaimTypes.Email, email, XmlSchemaString, Options.AuthenticationType)); + } await Options.Provider.Authenticated(context);