How to use OAuth2/OpenIDConnect flow as sessionless, without cookies

Zach Gardner 0 Reputation points
2023-08-14T20:01:50.8233333+00:00

When I use the OpenIDConnect authentication flow for a .NET Core 6 app, it only supports doing so with cookies, leveraging a session to store the information. If I want to create a microservice implementation that is stateless, and does not use sessions, how can I use OpenIDConnect?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,815 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Vahid Ghafarpour 23,120 Reputation points
    2023-08-14T20:27:21.5766667+00:00

  2. SurferOnWww 4,156 Reputation points
    2023-08-15T01:07:05.8233333+00:00

    Can the following Duende Software document help?

    Protecting an API using Client Credentials

    The above document describes the token-based (not cookie-based) authentication using the OpenID Connect protocol.


  3. Bruce (SqlWork.com) 74,851 Reputation points
    2023-08-15T15:40:59.38+00:00

    a persistent storage is only required if the web service needs to make an api call on the behalf of a user (get token silently). in this case the user access (and refresh) token is stored for use with subsequent requests. if your service does not need a user access token, then no session is required. the cookie has the user identification.

    but a micro-service is not typically a browser web site, its an api. I would expect it to use bearer tokens rather than cookie authentication. this does not require session.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.