diff --git a/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj b/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj
index e1c23384..46bd85c8 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj
+++ b/src/Infrastructure/BotSharp.OpenAPI/BotSharp.OpenAPI.csproj
@@ -18,16 +18,19 @@
+
+
+
diff --git a/src/Infrastructure/BotSharp.OpenAPI/BotSharpOpenApiExtensions.cs b/src/Infrastructure/BotSharp.OpenAPI/BotSharpOpenApiExtensions.cs
index 1a98f377..1d36f597 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/BotSharpOpenApiExtensions.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/BotSharpOpenApiExtensions.cs
@@ -80,6 +80,7 @@ public static class BotSharpOpenApiExtensions
};
});
+ // GitHub OAuth
if (!string.IsNullOrWhiteSpace(config["OAuth:GitHub:ClientId"]) && !string.IsNullOrWhiteSpace(config["OAuth:GitHub:ClientSecret"]))
{
builder = builder.AddGitHub(options =>
@@ -90,6 +91,16 @@ public static class BotSharpOpenApiExtensions
});
}
+ // Google Identiy OAuth
+ if (!string.IsNullOrWhiteSpace(config["OAuth:Google:ClientId"]) && !string.IsNullOrWhiteSpace(config["OAuth:Google:ClientSecret"]))
+ {
+ builder = builder.AddGoogle(options =>
+ {
+ options.ClientId = config["OAuth:Google:ClientId"];
+ options.ClientSecret = config["OAuth:Google:ClientSecret"];
+ });
+ }
+
// Add services to the container.
services.AddControllers()
.AddJsonOptions(options =>
diff --git a/src/Infrastructure/BotSharp.OpenAPI/Controllers/UserController.cs b/src/Infrastructure/BotSharp.OpenAPI/Controllers/UserController.cs
index 34ed7a0e..65b7a46a 100644
--- a/src/Infrastructure/BotSharp.OpenAPI/Controllers/UserController.cs
+++ b/src/Infrastructure/BotSharp.OpenAPI/Controllers/UserController.cs
@@ -1,4 +1,3 @@
-using AspNet.Security.OAuth.GitHub;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using System.ComponentModel.DataAnnotations;
@@ -71,18 +70,15 @@ public class UserController : ControllerBase
var identiy = _services.GetRequiredService();
var accessor = _services.GetRequiredService();
var claims = accessor.HttpContext.User.Claims;
- if (claims.Any(x => x.Type == GitHubAuthenticationConstants.Claims.Name))
+ user = await _userService.CreateUser(new User
{
- user = await _userService.CreateUser(new User
- {
- Email = identiy.Email,
- UserName = identiy.UserName,
- FirstName = identiy.FirstName,
- LastName = identiy.LastName,
- Source = "GitHub",
- ExternalId = identiy.Id,
- });
- }
+ Email = identiy.Email,
+ UserName = identiy.UserName,
+ FirstName = identiy.FirstName,
+ LastName = identiy.LastName,
+ Source = claims.First().Issuer,
+ ExternalId = identiy.Id,
+ });
}
return UserViewModel.FromUser(user);
}
diff --git a/src/WebStarter/appsettings.json b/src/WebStarter/appsettings.json
index 7694990a..c040b498 100644
--- a/src/WebStarter/appsettings.json
+++ b/src/WebStarter/appsettings.json
@@ -17,6 +17,10 @@
"GitHub": {
"ClientId": "",
"ClientSecret": ""
+ },
+ "Google": {
+ "ClientId": "",
+ "ClientSecret": ""
}
},