-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fail to request the OIDC authenticated data API(Appsync) #507
Comments
Hello, @zxkane and thanks for opening this issue. I'm going to transfer it to our new |
Hi @zxkane 👋 thanks for raising this issue! Have you seen these AppSync docs on using OIDC tokens? It might help unblock you on this issue. You may need to simply add a random prefix/suffix to the token when you pass it in to the From this page: https://arc.net/l/quote/ttwmpksc
|
Hi, I don't think it's an issue of the AppSync endpoint generated by Amplify Gen2. The AppSync endpoint with OIDC authentication created by Gen2 works well. I can use the client with the right token to access it. However, using the Amplify data client with the OIDC auth provider does not work as expected. I used the below workaround to bypass the dependency for Amplify's auth. const client = generateClient<Schema>({
authMode: 'lambda',
headers: async () => {
const session = await fetch('/api/auth/session').then(res => res.json());
return {
Authorization: `Bearer ${session?.idToken}`
};
}
}); I'm still confused as to why the OIDC authMode in the data client requires the Cognito user pool (assuming the |
@zxkane Thank you for sharing the workaround. I'm actually a bit surprised that using This issue is very similar to this one I have reproduced before, the difference being they were using AppSync Events and there was an auth resource/cognito user pool as well. In any case, I'll create a reproduction app with OIDC tokens to reproduce this issue and also test different scenarios to see what's expected behavior and what's not working as expected. In the meantime, please take a look at that other issue. That one required setting up a I just came across this in the docs which seems to align with the above and explains that it's even required for Let me know if that helps! Thank you for your patience. |
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
GraphQL API
Amplify Version
v6
Amplify Categories
api
Backend
Amplify Gen 2
Environment information
Describe the bug
I have a web application built on Amplify Gen2 to manage AWS infra and Next.js for the frontend application.
Due to some limitation, I can not create a Cognito User Pool for user authentication; I'm using an external OIDC provider instead. It works well with the data API with an external OIDC provider for authentication and authorization.
And I use
next-auth
instead ofaws-amplify/auth
for user authentication in the web application. I got NoValidAuthTokens: No federated jwt when accessing the data api in the web application.Below is the code snippet for what I'm doing with the data API request.
According to the source code of Amplify JS, it also checks the Auth storage to find the login session, which does not fit my case to directly log in with a third-party OIDC provider, not Cognito User Pool.
Expected behavior
Amplify client has a way to supply the access token / id token for auth mode 'oidc'.
Reproduction steps
see above
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: