跳至內容
從 NextAuth.js v4 遷移?請閱讀 我們的遷移指南.

providers/cognito

內建 Cognito 整合。

CognitoProfile

繼承自

屬性

email

email: string;

name

name: string;

picture

picture: string;

sub

sub: string;

default()

default<P>(options): OAuthConfig<P>

將 Cognito 登入新增到您的頁面。

設定

回調 URL

https://example.com/api/auth/callback/cognito

組態

import { Auth } from "@auth/core"
import Cognito from "@auth/core/providers/cognito"
 
const request = new Request(origin)
const response = await Auth(request, {
  providers: [
    Cognito({
      clientId: COGNITO_CLIENT_ID,
      clientSecret: COGNITO_CLIENT_SECRET,
      issuer: COGNITO_ISSUER,
    }),
  ],
})

資源

注意事項

您需要選擇您的 AWS 區域以進入 Cognito 儀表板。

💡

發行者是一個 URL,看起來像這樣:https://cognito-idp.\{region\}.amazonaws.com/\{PoolId\}

PoolId 來自 Cognito 中的「一般設定」,不要與應用程式用戶端 ID 混淆。

⚠️

請確保您選擇所有適當的用戶端設定,否則 OAuth 流程將無法運作。

預設情況下,Auth.js 假設 Cognito 提供者基於 Open ID Connect 規範。

💡

Cognito 提供者帶有預設設定。若要覆寫您的使用案例的預設值,請查看自訂內建 OAuth 提供者

免責聲明 如果您認為您在預設設定中發現錯誤,您可以開啟一個問題

Auth.js 嚴格遵守規範,並且不對提供者偏離規範的任何行為負責。您可以開啟一個問題,但如果問題是不符合規範,我們可能不會尋求解決方案。您可以在討論區中尋求更多協助。

類型參數

類型參數
P extends CognitoProfile

參數

參數類型
optionsOAuthUserConfig<P>

返回

OAuthConfig<P>

Auth.js © Balázs Orbán 和團隊 -2024