Skip to content

Commit

Permalink
update oauth
Browse files Browse the repository at this point in the history
  • Loading branch information
aacebo committed Jan 18, 2024
1 parent 72c2be0 commit 4165baa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
11 changes: 5 additions & 6 deletions dotnet/samples/06.auth.oauth.bot/AdapterWithErrorHandler.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
using Microsoft.Bot.Builder.Integration.AspNet.Core;
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Bot.Connector.Authentication;
using Microsoft.Bot.Builder.TraceExtensions;
using Microsoft.Teams.AI;

namespace BotAuth
{
public class AdapterWithErrorHandler : CloudAdapter
public class AdapterWithErrorHandler : TeamsAdapter
{
public AdapterWithErrorHandler(BotFrameworkAuthentication auth, ILogger<CloudAdapter> logger)
: base(auth, logger)
public AdapterWithErrorHandler(IConfiguration configuration, ILogger<TeamsAdapter> logger)
: base(configuration, null, logger)
{
OnTurnError = async (turnContext, exception) =>
{
Expand Down
2 changes: 1 addition & 1 deletion dotnet/samples/06.auth.oauth.bot/BotAuth.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PackageReference Include="AdaptiveCards.Templating" Version="1.3.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.21.1" />
<PackageReference Include="Microsoft.Identity.Web.TokenCache" Version="2.16.0" />
<PackageReference Include="Microsoft.Teams.AI" Version="1.0.*-*" />
<PackageReference Include="Microsoft.Teams.AI" Version="1.1.*-*" />
</ItemGroup>

<!-- Exclude Teams Toolkit files from build output, but can still be viewed from Solution Explorer -->
Expand Down
6 changes: 3 additions & 3 deletions dotnet/samples/06.auth.oauth.bot/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
// Create the Cloud Adapter with error handling enabled.
// Note: some classes expect a BotAdapter and some expect a BotFrameworkHttpAdapter, so
// register the same adapter instance for both types.
builder.Services.AddSingleton<CloudAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<CloudAdapter>());
builder.Services.AddSingleton<TeamsAdapter, AdapterWithErrorHandler>();
builder.Services.AddSingleton<IBotFrameworkHttpAdapter>(sp => sp.GetService<TeamsAdapter>());

// Create the storage to persist turn state
builder.Services.AddSingleton<IStorage, MemoryStorage>();
Expand All @@ -35,7 +35,7 @@
builder.Services.AddTransient<IBot>(sp =>
{
IStorage storage = sp.GetService<IStorage>();
BotAdapter adapter = sp.GetService<CloudAdapter>();
TeamsAdapter adapter = sp.GetService<TeamsAdapter>();
AuthenticationOptions<AppState> options = new();
options.AddAuthentication("graph", new OAuthSettings()
Expand Down

0 comments on commit 4165baa

Please sign in to comment.