How to store an authentication token?

Torge Stehr 0 Reputationspunkte
2024-04-18T07:15:26.76+00:00

Hello, this is probably a simple question, but I just can't find a proper answer: How to store an authentication token? I usually use Supabase for authentication. My Outlook add-in works wonderfully in the Outlook desktop app but not in the browser. The problem is that Supabase sets the auth cookies with Same-Site: Lax. Since these become third-party cookies in the browser, they can't be read on the server side. Therefore, I adjusted the cookie options so that the auth cookies are set with Same-Site: none; Secure; Partitioned. This makes the auth flow work with Supabase in Chrome but not, for example, in Safari. But I don't want to focus on Supabase specifically, rather on how you store tokens in general. Since third-party cookies are not an option, I considered storing the session on the server side. I would associate the user with Office.auth.getAccessToken() and use it to call up the session. However, I've read that Office.auth.getAccessToken() also doesn't always work and that it needs a fallback solution. But what options are left? Should I store the auth token in local storage?

Microsoft 365 und Office | Installieren, Einlösen, Aktivieren | Geschäftlich | Windows
Gemeindehaus | Wird nicht überwacht
0 Kommentare Keine Kommentare
{zählen} Stimmen

1 Antwort

Sortieren nach: Hilfsbereiteste
  1. Ivan Dragov (CONCENTRIX Corporation) 2,640 Reputationspunkte Microsoft Externe Mitarbeiter
    2024-04-19T05:24:59.1866667+00:00

    Hallo Torge,

    Single Sign-On (SSO) ist der einzige verfügbare Dienst, den Office im Web für Office-Add-Ins verwendet, wie hier erläutert:

    Single Sign-on service for Office Add-ins rolls out in Office on the web

    getAccessToken ruft den Azure Active Directory V 2.0-Endpunkt auf, um ein Zugriffstoken für das Add-In Deiner Web-Anwendung zu erhalten. Wenn Dein Add-In beispielsweise auf einer älteren Version von Office geladen wird, die SSO nicht unterstützt, schlägt der Aufruf von getAccessToken fehl. In diesem Fall gibt es für Outlook-Add-Ins ein empfohlenes Notfallsystem. Weitere Informationen findest Du unter Szenario: Implementieren von Single Sign-On bei Ihrem Dienst in einem Outlook-Add-In. Als Referenz kannst Du Dich diese Artikel ansehen:

    Aktivieren des einmaligen Anmeldens (Single Sign-On, SSO) in einem Office-Add-In > Implementierung eines Fallback-Authentifizierungssystems

    Gruß,

    Ivan Dragov

    0 Kommentare Keine Kommentare

Deine Antwort

Antworten können vom Frageautor als 'Akzeptiert' und von den Moderatoren als 'Empfohlen' markiert werden, was den Nutzern hilft, die Lösung des Problems des Autors zu erkennen.