Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to add Authorization: Bearer header to Strawberry Shake client after login in Blazor Server?

$
0
0

I'm using Blazor Server with Strawberry Shake 15.1.10.0 to consume a GraphQL API.

Here's the flow:

  1. User logs in via a regular API call (SignInAsync(username, password))

  2. The API returns a JWT token (accessCode)

  3. I need this token to be sent as:

    Authorization: Bearer <token>

    in all subsequent GraphQL requests made by the IClient (Strawberry Shake)

  4. After login, I call a query like UserDetailsQuery to fetch user data before marking the user as authenticated

Problem:ITemporaryTokenStore (scoped) set in login page → never reaches AuthHandler.

I've already tried:

  • HttpContext.RequestServices
  • CreateScope()
  • ConfigureHttpClient(sp, ...)

All return null. Only works with a singleton → unsafe for multiple users.

Question: how to securely pass the token to Strawberry Shake before authentication, using scoped services and supporting multiple users?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>