fix onepassword router (#3105)

This commit is contained in:
LawyZheng
2025-08-05 23:33:08 +08:00
committed by GitHub
parent 00c9446023
commit 1e315e39cd
2 changed files with 8 additions and 9 deletions

View File

@@ -17,9 +17,9 @@ export function useOnePasswordToken() {
useQuery<OnePasswordTokenApiResponse>({ useQuery<OnePasswordTokenApiResponse>({
queryKey: ["onePasswordToken"], queryKey: ["onePasswordToken"],
queryFn: async () => { queryFn: async () => {
const client = await getClient(credentialGetter); const client = await getClient(credentialGetter, "sans-api-v1");
return await client return await client
.get("/auth-tokens/onepassword") .get("/credentials/onepassword/get")
.then((response) => response.data.token) .then((response) => response.data.token)
.catch(() => null); .catch(() => null);
}, },
@@ -27,9 +27,9 @@ export function useOnePasswordToken() {
const createOrUpdateTokenMutation = useMutation({ const createOrUpdateTokenMutation = useMutation({
mutationFn: async (data: CreateOnePasswordTokenRequest) => { mutationFn: async (data: CreateOnePasswordTokenRequest) => {
const client = await getClient(credentialGetter); const client = await getClient(credentialGetter, "sans-api-v1");
return await client return await client
.post("/auth-tokens/onepassword", data) .post("/credentials/onepassword/create", data)
.then((response) => response.data as CreateOnePasswordTokenResponse); .then((response) => response.data as CreateOnePasswordTokenResponse);
}, },
onSuccess: () => { onSuccess: () => {

View File

@@ -375,7 +375,7 @@ async def get_credentials(
@base_router.get( @base_router.get(
"/credentials/onepassword", "/credentials/onepassword/get",
response_model=CreateOnePasswordTokenResponse, response_model=CreateOnePasswordTokenResponse,
summary="Get OnePassword service account token", summary="Get OnePassword service account token",
description="Retrieves the current OnePassword service account token for the organization.", description="Retrieves the current OnePassword service account token for the organization.",
@@ -385,7 +385,7 @@ async def get_credentials(
}, },
) )
@base_router.get( @base_router.get(
"/credentials/onepassword/", "/credentials/onepassword/get/",
response_model=CreateOnePasswordTokenResponse, response_model=CreateOnePasswordTokenResponse,
include_in_schema=False, include_in_schema=False,
) )
@@ -400,7 +400,6 @@ async def get_onepassword_token(
organization_id=current_org.organization_id, organization_id=current_org.organization_id,
token_type=OrganizationAuthTokenType.onepassword_service_account, token_type=OrganizationAuthTokenType.onepassword_service_account,
) )
if not auth_token: if not auth_token:
raise HTTPException( raise HTTPException(
status_code=404, status_code=404,
@@ -425,7 +424,7 @@ async def get_onepassword_token(
@base_router.post( @base_router.post(
"/credentials/onepassword", "/credentials/onepassword/create",
response_model=CreateOnePasswordTokenResponse, response_model=CreateOnePasswordTokenResponse,
summary="Create or update OnePassword service account token", summary="Create or update OnePassword service account token",
description="Creates or updates a OnePassword service account token for the current organization. Only one valid token is allowed per organization.", description="Creates or updates a OnePassword service account token for the current organization. Only one valid token is allowed per organization.",
@@ -435,7 +434,7 @@ async def get_onepassword_token(
}, },
) )
@base_router.post( @base_router.post(
"/credentials/onepassword/", "/credentials/onepassword/create/",
response_model=CreateOnePasswordTokenResponse, response_model=CreateOnePasswordTokenResponse,
include_in_schema=False, include_in_schema=False,
) )