Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide examples for including user attributes in JWT #141

Closed
fungc-io opened this issue Jan 12, 2023 · 1 comment
Closed

Provide examples for including user attributes in JWT #141

fungc-io opened this issue Jan 12, 2023 · 1 comment
Labels

Comments

@fungc-io
Copy link
Member

A very common use case that can be achieved by the new event hook feature

import { EventUserSessionJWTPreCreate, HookResponse } from "https://deno.land/x/authgear_deno_hook@v0.3.0/mod.ts";

export default async function(e: EventUserSessionJWTPreCreate): Promise<HookResponse> {
  // Write your hook with the help of the type definition.
  return { 
    mutations:{
      jwt: {
        payload:{
          ...e.payload.jwt.payload,
          standard_attributes: e.payload.user.standard_attributes,
          custom_attributes: e.payload.user.custom_attributes
        }
      }
    },
    is_allowed: true 
  };
}
@fungc-io fungc-io added the docs label Jan 12, 2023
@Boburmirzo
Copy link

@fungc-io Thanks for reporting this! We added a separate How-to guide for this case:

https://docs.authgear.com/how-to-guide/integration/add-custom-fields-to-a-jwt-access-token

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants