cps-user3
CCConvex Community
•Created by cps-user3 on 6/4/2024 in #support-community
Null Response from ctx.auth.getUserIdentity() in Next.js API
I tested the method you provided and it works well. Thank you so much!
11 replies
CCConvex Community
•Created by cps-user3 on 6/4/2024 in #support-community
Null Response from ctx.auth.getUserIdentity() in Next.js API
Thank you for the response!
So, does it mean that when using 'httpAction' and passing jwtToken to headers, i can use 'ctx.auth.getUserIdentity();'?
import { httpRouter } from "convex/server";
import { httpAction } from "./_generated/server";
const http = httpRouter();
http.route({
path: "/getIdentity",
method: "GET",
handler: httpAction(async (ctx, request) => {
const identity = await ctx.auth.getUserIdentity();
return new Response(JSON.stringify(identity), {
headers: {
"content-type": "application/json",
},
status: 200,
});
}),
});
export default http;
If we only pass jwtToken to headers when invoking the 'httpAction' elsewhere, can i then use 'identity'?
11 replies
CCConvex Community
•Created by cps-user3 on 6/4/2024 in #support-community
Null Response from ctx.auth.getUserIdentity() in Next.js API
Thank you for answering!
Next.js is accessing Convex in the following way.
"use client";
import { ReactNode } from "react";
import { ConvexReactClient } from "convex/react";
import { ConvexProviderWithAuth0 } from "convex/react-auth0";
import { Auth0Provider } from "@auth0/auth0-react";
const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);
export default function ConvexClientProvider({
children,
}: {
children: ReactNode;
}) {
return (
<Auth0Provider
domain={process.env.NEXT_PUBLIC_AUTH0_DOMAIN!}
clientId={process.env.NEXT_PUBLIC_AUTH0_CLIENT_ID!}
authorizationParams={{
redirect_uri:
typeof window === "undefined" ? undefined : window.location.origin,
}}
useRefreshTokens={true}
cacheLocation="localstorage"
>
<ConvexProviderWithAuth0 client={convex}>
{children}
</ConvexProviderWithAuth0>
</Auth0Provider>
);
}
I am wondering if there is a way to use await ctx.auth.getUserIdentity() when a user logged into a Flutter app using the same Auth0 domain tries to call the Next.js app's API to fetch data.
How can Convex recognize that the user is authenticated?
11 replies
CCConvex Community
•Created by cps-user3 on 6/4/2024 in #support-community
Null Response from ctx.auth.getUserIdentity() in Next.js API
Yes, of course.Could the result of await ctx.auth.getUserIdentity(); be null because I am accessing Convex through the Next.js API from a Flutter app? If so, is there another way to pass the authentication token to the Convex backend?
11 replies
CCConvex Community
•Created by cps-user3 on 5/29/2024 in #support-community
How to call useQuery and useMutation in app/api/route.ts?
Oh, thank you so much!!!
3 replies
CCConvex Community
•Created by cps-user3 on 1/29/2024 in #support-community
How to update identity.name
Yes, I got it. Thank you so much.
3 replies
CCConvex Community
•Created by cps-user3 on 1/3/2024 in #support-community
Is there a way to modify the arguments of a schedule function?
Thank you so much!
4 replies
CCConvex Community
•Created by cps-user3 on 12/22/2023 in #support-community
How can I cancel scheduled?
Thank you so much.
6 replies
CCConvex Community
•Created by cps-user3 on 12/22/2023 in #support-community
How can I cancel scheduled?
Thank you. I didn't think of a version.
I'd like to ask you one more question.
I implemented the payment every month, and I want to store the ID of the schedule in the database.
Is there any good way?
export const paymentSchedule = action({
args: {
id: v.id("apiLimit"),
billingKey: v.string(),
customerKey: v.string(),
customerName: v.optional(v.any())
},
handler: async (ctx, { id, billingKey, customerKey, customerName }) => {
const paymentResponse = await sendTossPayment(billingKey, customerKey, customerName);
if (paymentResponse.status === 'DONE') {
const paymentTime = Date.parse(paymentResponse.approvedAt);
await ctx.scheduler.runAfter(
30 * 24 * 60 * 60 * 1000,
api.payments.paymentSchedule,
{ id, billingKey, customerKey, customerName }
);
};
}
});
6 replies