The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
code_challenge_method must be 'S256'
Kiran Ka58dd7650c73
diff --git a/apps/web/app/app.dub.co/(auth)/oauth/authorize/authorize-form.tsx b/apps/web/app/app.dub.co/(auth)/oauth/authorize/authorize-form.tsxindex 0dbac0e3fa..88fc4769c2 100644--- a/apps/web/app/app.dub.co/(auth)/oauth/authorize/authorize-form.tsx+++ b/apps/web/app/app.dub.co/(auth)/oauth/authorize/authorize-form.tsx@@ -76,14 +76,18 @@ export const AuthorizeForm = ({<input type="hidden" name="client_id" value={client_id} /><input type="hidden" name="redirect_uri" value={redirect_uri} /><input type="hidden" name="response_type" value={response_type} />- <input type="hidden" name="state" value={state} /><input type="hidden" name="scope" value={scope.join(",")} />- <input type="hidden" name="code_challenge" value={code_challenge} />- <input- type="hidden"- name="code_challenge_method"- value={code_challenge_method}- />+ {state && <input type="hidden" name="state" value={state} />}+ {code_challenge && (+ <input type="hidden" name="code_challenge" value={code_challenge} />+ )}+ {code_challenge_method && (+ <input+ type="hidden"+ name="code_challenge_method"+ value={code_challenge_method}+ />+ )}<p className="text-sm text-gray-500">Select a workspace to grant API access to</p>diff --git a/apps/web/lib/zod/schemas/oauth.ts b/apps/web/lib/zod/schemas/oauth.tsindex fb2cb8d822..58dbaf7418 100644--- a/apps/web/lib/zod/schemas/oauth.ts+++ b/apps/web/lib/zod/schemas/oauth.ts@@ -68,10 +68,13 @@ export const authorizeRequestSchema = z.object({message: "Invalid scopes",},),-- // PKCE flowcode_challenge: z.string().max(190).optional(),- code_challenge_method: z.string(z.enum(["plain", "S256"])).optional(),+ code_challenge_method: z+ .string()+ .refine((method) => method === "S256", {+ message: "code_challenge_method must be 'S256'",+ })+ .optional(),});// Schema for OAuth2.0 code exchange request@@ -81,8 +84,6 @@ export const authCodeExchangeSchema = z.object({client_secret: z.string().optional(),code: z.string().min(1, "Missing code"),redirect_uri: z.string().url({ message: "redirect_uri must be a valid URL" }),-- // PKCE flowcode_verifier: z.string().max(190).optional(),});@@ -94,6 +95,7 @@ export const refreshTokenSchema = z.object({refresh_token: z.string().min(1, "Missing refresh_token"),});+// Token grant schemaexport const tokenGrantSchema = z.discriminatedUnion("grant_type",[authCodeExchangeSchema, refreshTokenSchema],@@ -104,6 +106,7 @@ export const tokenGrantSchema = z.discriminatedUnion(},);+// Schema to represent an authorized OAuth app with userexport const oAuthAuthorizedAppSchema = z.object({id: z.string(),