We currently have an SPFX webpart (React application) that uses SSO and then calls Graph APIs 'on behalf of' the user. The SPFX package is installed into SharePoint/Teams where consent to use the Graph APIs are agreed by the Administrator installing the package. We want a simpler user experience where they are able to download the app from the Microsoft Teams App Store.
Is it possible to use the Microsoft Graph Toolkit 2.0 with silent authentication to provide the same seamless experience as we have with the SPFX webpart? The only samples I have been able to find use the TeamsProvider but the login must be initiated by the user and require a popup to be displayed. Ultimately, we are hoping for an experience with no popups. Is this possible? Can you provide a link to working samples that make calls to Graph APIs that require extra scopes e.g. Mail.Read?
I have also seen many examples using ADAL rather than MSAL or the latest Microsoft Graph Toolkit. Should we be using ADAL or MSAL to achieve this?
Below shows the the code working with the TeamsProvider initialised in the App.tsx and the Auth.tsx popup when the user initiates login with the Login component from the Teams tab:
App.tsx:
import { TeamsProvider } from '@microsoft/mgt-teams-provider';
function App() {
// Initialize the Microsoft Teams SDK
microsoftTeams.initialize();
// Define Teams as the global provider.
TeamsProvider.microsoftTeamsLib = microsoftTeams;
Providers.globalProvider = new TeamsProvider(AppConfiguration.TeamsConfiguration());
Auth.tsx
import React, {useEffect, Fragment} from 'react';
import * as microsoftTeams from "@microsoft/teams-js";
import {TeamsProvider} from '@microsoft/mgt-teams-provider';
const Authentication: React.FC = () => {
useEffect(() => {
TeamsProvider.microsoftTeamsLib = microsoftTeams;
TeamsProvider.handleAuth();
});