/oauth/userinfo 显然不存在。您可以使用 OpenShift API 本身获取用户信息/apis/user.openshift.io/v1/users/{name}
我缺少的是当您将 ~ (波浪号)放入路径时返回当前登录的用户,所以 GET /apis/user.openshift.io/v1/users/~
{
kind: "User",
apiVersion: "user.openshift.io/v1",
metadata: {
name: "kube:admin",
selfLink: "/apis/user.openshift.io/v1/users/kube%3Aadmin",
creationTimestamp: null,
},
identities: null,
groups: [
"system:authenticated",
"system:cluster-admins",
],
}
当我使用 CodeReady 容器进行开发时,我的 URL 设置如下(Node.js/Next.js/next-auth):
export const OpenShiftOAuthProvider = {
id: "openshift",
name: "OpenShift",
type: "oauth",
version: "2.0",
params: { grant_type: "authorization_code" },
scope: "user:full",
idToken: false,
accessTokenUrl: "https://oauth-openshift.apps-crc.testing/oauth/token",
profileUrl: "https://api.crc.testing:6443/apis/user.openshift.io/v1/users/~",
authorizationUrl:
"https://oauth-openshift.apps-crc.testing/oauth/authorize?response_type=code",
clientId: "<yourclientid>",
clientSecret: "<yourclientsecret>"
async profile(profile) {
return {
id: profile.metadata.name,
name: profile.metadata.name
};
},
};