feat(SW-2116): RefId instead of confirmationNumber
This commit is contained in:
committed by
Michael Zetterberg
parent
7eeb0bbcac
commit
74d37dad93
@@ -3,7 +3,9 @@ import { trace, type Tracer } from "@opentelemetry/api"
|
||||
import { env } from "@/env/server"
|
||||
import { createCounter } from "@/server/telemetry"
|
||||
|
||||
import { auth } from "@/auth"
|
||||
import { getCacheClient } from "@/services/dataCache"
|
||||
import { isValidSession } from "@/utils/session"
|
||||
|
||||
import type { ServiceTokenResponse } from "@/types/tokens"
|
||||
|
||||
@@ -117,3 +119,12 @@ async function fetchServiceToken(scopes: string[]) {
|
||||
function getServiceTokenCacheKey(scopes: string[]): string {
|
||||
return `serviceToken:${scopes.join(",")}`
|
||||
}
|
||||
|
||||
export async function getUserOrServiceToken() {
|
||||
const serviceToken = await getServiceToken()
|
||||
const session = await auth()
|
||||
|
||||
return isValidSession(session)
|
||||
? session.token.access_token
|
||||
: serviceToken.access_token
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user