-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
getting NoValidAuthTokens: No federated jwt
errors on devices whilst they should stay logged in
#13541
Comments
Hello @mattiLeBlanc. Sorry for any inconvenience using the library, and thank you for providing the code snippets. Based on the code bellow, the
If you indeed are getting a |
No federated jwtNoValidAuthTokens: No federated jwt
errors on devices whilst they should stay logged inNoValidAuthTokens: No federated jwt
errors on devices whilst they should stay logged in
Hello, I can confirm that I am experiencing the same issue but on a Next.js v14 project. I'm using plain cognito (phone number + password) without any federated auth providers. I don't have any logic to sign out the user as in the OP's issue. Here's a snippet of how I initialize my client import amplifyConfig from "@repo/aws-exports";
Amplify.configure(amplifyConfig, { ssr: true });
ConsoleLogger.LOG_LEVEL = "DEBUG"; Then, I have the import { createServerRunner } from "@aws-amplify/adapter-nextjs";
import { generateServerClientUsingCookies } from "@aws-amplify/adapter-nextjs/api";
import { cookies } from "next/headers";
import config from "@repo/aws-exports";
export const ssrClient = generateServerClientUsingCookies({
cookies,
config,
authMode: "userPool",
});
export const { runWithAmplifyServerContext } = createServerRunner({
config,
}); This issue occurs anytime I try to use the ssrClient to perform a query to appsync. Initially, I was getting a different |
@ndaba1, thank you for the additional context here. We'll work on reproducing on our side and investigate this further. |
@cwomack any progress/updates on this ? |
Hi @ndaba1 your issue seemed different from the OP, I will follow up in your linked issue. Please take a look there. |
Hi @mattiLeBlanc I dug into the GraphQL API implementation and how it uses the In your comment in the code example:
How the "remove" is implemented? Are you revoking access token and refresh token on remove? That may happen that when In addition, can you confirm, have you enabled unauthenticated access (or guest access) in your identity pool? |
@HuiSF This my aws config with the section for the Angular app:
I authenticted and unauthenticated modes. My graphql function in my api.service looks like this:
The answer your question about removing a user session: What happens is we can logout a user from the client app via the admin app, by revoking their refresh token. Then when the user navigates anywhere in the client app, that bid of code in the try/catch will detect the user session is no longer valid and do a logout. Do you think that bit of code is responsible for our errors where our customers are apparently not logged in, whilst the refresh token is valid for 10 years? In angular I am using a custom error handler, which is pretty greedy and if there is a graphql authentitcation issue, it will immediately jump to an Error page.
We have a music streamin app and they will leave it open on a tablet for ever and sometimes trigger the above errors. |
@cwomack @HuiSF
I triggered this error in my test env by revoking the RefreshToken of the logged in user and when the AccessToken expired and I tried to do a graphql call, I got this error. The function The errors we are getting listed in the prev message above are triggered by customers. Can a refreshtoken be removed or denied by WIFI security settings in the facilties or because of ContentBlockers on the devives? However, if that error is triggered by the same bit of code, the refreshtoken must have been revoked on the cognito side or can a missing refreshToken in LocalStorage also trigger this error? |
By this flow, I don't think there is a way to make Amplify aware of that the refresh token stored in the client has been revoked, without actually using it to hit the service endpoint. If you need this forceful sign out function, I think you'd need to implement a mechanism that when you perform token revocation from your Admin app, to send a notification to your end-user facing client app, to clear tokens stored on the client and redirect to a sign-in page.
You mean with revoking these customers' token or no? |
@HuiSF So I am also looking at an interval based ping that checks every X time if the user still exists or is logged in. In regards to the other issue, the errors; I am still trying to find out but I noticed that if I remove the refreshtoken manually and let the accesstoken expire, I get the 'Fedarated JWT' error. So I need to figure out if those customers are either having contentblockers or if ther corporate wifi may be filtering out headers? Because how else does a JWT token get removed? |
@HuiSF @cwomack
and I wonder if it is because my Angular error handler is to greedy. Does the accessToken renewal trigger an unauthorised error on the first graphql request and then automatically fetch a new accessToken and try the query again, or will the query that happens just on the cusp of accesstoken expiry always fail? |
It's always that the GraphQL API requests the access token via the Have you able to capture the access token used to trigger the
You meant the RxJS used by the GraphQL API internally? Hum I don't think the retry would happen on |
@mattiLeBlanc, we'll close this one out as a duplicate since the last remaining issue here is what is captured in #13710. |
Before opening, please confirm:
JavaScript Framework
Angular
Amplify APIs
Authentication
Amplify Version
v6
Amplify Categories
auth, api
Backend
None
Environment information
System:
OS: macOS 14.4.1
CPU: (10) arm64 Apple M1 Max
Memory: 25.34 GB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.14.0 - /usr/local/bin/node
Yarn: 1.22.18 - ~/.npm-global/bin/yarn
npm: 8.19.1 - ~/.npm-global/bin/npm
pnpm: 9.0.0 - ~/.npm-global/bin/pnpm
Browsers:
Chrome: 126.0.6478.115
Safari: 17.4.1
npmPackages:
@angular-devkit/build-angular: 18.0.1 => 18.0.1
@angular/animations: 18.0.0 => 18.0.0
@angular/cdk: 18.0.0 => 18.0.0
@angular/cli: 18.0.1 => 18.0.1
@angular/common: 18.0.0 => 18.0.0
@angular/compiler: 18.0.0 => 18.0.0
@angular/compiler-cli: 18.0.0 => 18.0.0
@angular/core: 18.0.0 => 18.0.0
@angular/forms: 18.0.0 => 18.0.0
@angular/material: 18.0.0 => 18.0.0
@angular/material-moment-adapter: 18.0.0 => 18.0.0
@angular/platform-browser: 18.0.0 => 18.0.0
@angular/platform-browser-dynamic: 18.0.0 => 18.0.0
@angular/router: 18.0.0 => 18.0.0
@angular/youtube-player: 18.0.0 => 18.0.0
@aws-amplify/core: ^6.3.1 => 6.3.1
@aws-sdk/client-acm: ^3.379.1 => 3.577.0
@aws-sdk/client-appsync: ^3.379.1 => 3.577.0
@aws-sdk/client-cognito-identity: ^3.379.1 => 3.577.0
@aws-sdk/client-cognito-identity-provider: ^3.379.1 => 3.577.0
@aws-sdk/credential-provider-ini: ^3.379.1 => 3.577.0
@iplab/ngx-file-upload: ^17.0.0 => 17.1.0
@types/jasmine: ~4.3.0 => 4.3.6
@types/node: 18.0.6 => 18.0.6
@types/prettier: 2.6.0 => 2.6.0
@types/uuid: ^10.0.0 => 10.0.0
@types/vimeo__player: ^2.16.3 => 2.18.3
@types/youtube: ^0.0.47 => 0.0.47
@vimeo/player: ^2.18.0 => 2.23.0
angular-google-tag-manager: ^1.9.0 => 1.9.0
aws-amplify: ^6.3.4 => 6.3.4
aws-cdk: ^2.118.0 => 2.133.0
aws-cdk-lib: ^2.118.0 => 2.133.0
aws-sdk: ^2.1531.0 => 2.1624.0
axios: ^1.3.4 => 1.7.1
constructs: ^10.3.0 => 10.3.0
dayjs: ^1.11.7 => 1.11.11
jasmine-core: ~4.5.0 => 4.5.0
karma: ~6.4.0 => 6.4.3
karma-chrome-launcher: ~3.1.0 => 3.1.1
karma-coverage: ~2.2.0 => 2.2.1
karma-jasmine: ~5.1.0 => 5.1.0
karma-jasmine-html-reporter: ~2.0.0 => 2.0.0
material-icons: ^1.13.12 => 1.13.12
nosleep.js: ^0.12.0 => 0.12.0
rxjs: ~7.8.0 => 7.8.1
source-map-support: ^0.5.21 => 0.5.21
tailwindcss: ^3.4.3 => 3.4.3
ts-node: ^10.9.1 => 10.9.2
tslib: ^2.3.0 => 2.6.2
typescript: ~5.4.5 => 5.4.5
uuid: ^10.0.0 => 10.0.0
web-animations-js: ^2.3.2 => 2.3.2
zone.js: ~0.14.2 => 0.14.6
zxcvbn: ^4.4.2 => 4.4.2
npmGlobalPackages:
@angular/cli: 17.0.3
angular-http-server: 1.10.0
aws-cdk: 2.146.0
aws: 0.0.3-2
envinfo: 7.13.0
firebase-tools: 11.16.1
nativescript: 8.2.3
node-gyp: 8.4.1
npm: 8.19.1
pnpm: 9.0.0
yarn: 1.22.18
Describe the bug
My Angular error handler is reporting several Authentication related errors when doing Appsync calls:
No federated jwtNoValidAuthTokens: No federated jwt
Runtime error running query getMediaPath. Authmode Cognito. Error: NoValidAuthTokens: No federated jwt
Graphql Error running query getMediaPath. Authmode Cognito. Error: Unauthorized Error: Graphql Error running query getMediaPath. Authmode Cognito. Error: Unauthorized
These are all from different customers using our platform. I can't see in the stack trace what caused it because all the code is uglified and it happens in 3th party lib (amplify).
These users SHOULD be logged in, because our refresh token is set to multiple years expiry.
What may happen, they are running on a tablet which goes to sleep,and next day they come back to the application and it tries to do a query, maybe before the refreshtoken fetched a new accesstoken?
I can't reproduce it on my macbook, ipad of lenove android tablet.
Am I looking at headers being filtered by corporate networks or is their something else I should do?
I configure my angular app by the books:
I am using the latest version of Amplify 6 and before I was using Amplify 5.4 I didnt not get these JWT errors. Maybe just authorisation errors.
Expected behavior
I expect no authorisation errors if refreshtoken is valid and app is activated
Reproduction steps
I don't even know how to reproduce it myself.
It is happening on customers devices.
I realise this issue is vague, and it is for me too. I would have to get a hold of some of our users devices or talk their ID department to find out if has something to do with contentblockers or other security settings.
But I hope maybe these errors ring bells and you can give me a nudge in the right direction.
Code Snippet
// Put your code below this line.
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: