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

Documentation: Does naming of authkitLoader mean it is just for loaders? #20

Open
MattyBalaam opened this issue Aug 28, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@MattyBalaam
Copy link

I am maybe just misdirected by the naming here - Can you call authkitLoader inside a remix action as well? We need to get tokens to call endpoints in our actions and I’m not 100% sure that you can use it in an action.

@PaulAsjes PaulAsjes added the enhancement New feature or request label Aug 29, 2024
@PaulAsjes
Copy link
Collaborator

Hey there, although authkitLoader isn't technically supposed to be used in Remix actions, there is a workaround to get it doing what you want.

I'm going to leave this issue open as a reminder to add a Remix specific method for getting the user data, but in the meanwhile the following should work:

export async function action({ request }: ActionFunctionArgs) {
  const resp = await authkitLoader({
    request,
    params: {},
    context: {},
  });

  const { accessToken } = await resp.json();

  console.log('action:', accessToken);

  // make follow up API calls with the access token  
}

The above works because our loader doesn't require either params or context to function, just the request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants