cor*_*san 6 javascript amazon-cognito react-native firebase-authentication aws-amplify
我需要有关设置 Firebase Auth + Amplify GraphQL 的帮助。我正在尝试使用联合签名securetoken.google.com/PROJECT-ID作为提供者登录,它似乎可以正常登录,因为当我打电话时Auth.currentAuthenticatedUser()我得到了令牌,而在侦听集线器"signIn"事件时我得到了令牌。我的问题是向我的 GraphQL API 发出经过身份验证的请求。
const signIn = async () => {
try {
// already logged in using firebase so I just need to get the token from the current user
const tokenResult = await currentUser?.getIdTokenResult()
await Auth.federatedSignIn('securetoken.google.com/PROJECT-ID', {
token: tokenResult?.token,
})
const res = await Auth.currentAuthenticatedUser()
console.log('token', res.token) // eyjhxxxxxxxxxx...
} catch (error) {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
const client = new AWSAppSyncClient({
url: AppSyncConfig.aws_appsync_graphqlEndpoint,
region: AppSyncConfig.aws_appsync_region,
auth: {
type: AppSyncConfig.aws_appsync_authenticationType,
jwtToken: () => getToken(),
},
})
const getToken = async () => {
const token = await Cache.getItem('@accessToken')
return token
}
Run Code Online (Sandbox Code Playgroud)
打电话时Auth.currentSession()我得到"No current user". 此外,当我尝试获取数据时,我确实在 Authorization 标头中看到了令牌。
| 归档时间: |
|
| 查看次数: |
648 次 |
| 最近记录: |