Using Easy Auth in Azure from an SPA web client

195 views Asked by At

Given an Azure Function based API, setup to use App Service Authentication (Easy Auth)...

Authorization works as expected when using the browser because auth cookies are present e.g.

https://example.com/.auth/login/aad

then

Https://example.com/.auth/me

to prove and get the authenticated user json.

However, when programmatically trying to access the latter, e.g. using fetch a 401 (Unauthorised) as configured is returned.

It appears that when using the browser to navigate the authentication cookies are intrinsically used to establish authentication and the user data is returned.

What is the process for using that authentication programmatically in JS/TS from an application e.g. Svelte/React/Vue SPA?

0

There are 0 answers