Auth0 not returning user

I have apollo code that I’ve been using for a few months - suddenly I’m not getting a user returned. I can retrieve my list of accounts, so I know the jwt is working. Did the encapsulation of the user change, or did the request change? I am not seeing it in the response that used to contain it.

if it helps, my apollo server implementation is below. user is always null.

const server = new ApolloServer({
subscriptions: false,
context: ({ req }) => {
const user = req.user || null;
return { user };

Hi @lastneutrino,

In order to look into this a bit more, would you mind providing a few more details about the implementation?

How is the ApolloClient setting context?

For example from the Apollo/React example tutorial:

import auth from './Auth';
const client = new ApolloClient({
  uri: "http://localhost:4000/graphql",
  request: operation => {
    operation.setContext(context => ({
      headers: {
        authorization: auth.getIdToken(),

Also, what technologies are you using (framework, Auth0 SDK, etc.)



1 Like

This look ok?

const gateway = new ApolloGateway({
serviceList: [
name: “accounts”, url: process.env.ACCOUNTS_SERVICE_URL
buildService({ url }) {
return new RemoteGraphQLDataSource({
willSendRequest({ request, context }) {
console.log(“User” + context.user)
context.user ? JSON.stringify(context.user) : null

Hm, it looks like the user is being set to the request headers, but the ApolloServer is expecting it as a property of the request. Maybe if the ApolloServer used req.headers.user it would not be null. It is hard to determine without the full context, though.

i agree. i’ll find a better debugger.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.