You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to authenticate using the login function, the callback URL (/auth/callback) gets stuck if the user is not already authenticated. However, if the user is already authenticated and starts the CLI with the login function, everything works as intended.
Steps to Reproduce
Start the CLI and call the login command.
The browser opens the authentication URL: https://partner.zid.sa/cli/authorized --> https://partner.zid.sa/login.
If the user is not already authenticated, (live session).
Observe that the callback URL (/auth/callback) does not get triggered to GET TOKEN.
Expected Behavior
The callback URL should be triggered after the user inputs their credentials and the token should be retrieved successfully.
Actual Behavior
The callback URL (/auth/callback) gets stuck and does not retrieve the token if the user is not already authenticated.
Troubleshooting Steps Taken
Browser Caching: Cleared browser cache to ensure the authentication process starts fresh.
Network Issues: Confirmed that there are no network issues or firewalls blocking the request to http://localhost:4444/auth/callback.
Port Related Issue : Ensured the port is free and forwarding from origin
Additional Information
The issue does not occur if the user is already authenticated.
Added additional logging to trace the flow of the authentication process.
Code Snippet
constlogin=async(port: number=4444,): Promise<void>=>{logger.log('Starting authentication process...');constauthUrl=`https://partner.zid.sa/cli/authorized`;logger.log('Opening Zid Partner Dashboard in your default browser...');awaitopen(authUrl);constapp=express();app.use(cors());constserver=app.listen(port,()=>{logger.log(`Listening for authentication callback on http://localhost:${port}/auth/callback`);});app.get('/auth/callback',(req,res)=>{logger.log('Received callback request');console.log(req.query);constauthToken=req.query.token;if(authToken&&typeofauthToken==='string'){logger.log('Token received:',authToken);if(!setToken(authToken)){res.send('Failed to save token.');logger.log('Failed to save token.');server.close();return;}res.send('Authentication successful! You can close this window.');logger.log('Authentication successful!');}else{letmsg='Authentication failed.';res.send(msg);logger.log(msg,'red');}server.close();});}
The text was updated successfully, but these errors were encountered:
Authentication Callback Issue
Environment
Description
When attempting to authenticate using the
login
function, the callback URL (/auth/callback
) gets stuck if the user is not already authenticated. However, if the user is already authenticated and starts the CLI with thelogin
function, everything works as intended.Steps to Reproduce
login
command.https://partner.zid.sa/cli/authorized --> https://partner.zid.sa/login
./auth/callback
) does not get triggered toGET
TOKEN.Expected Behavior
The callback URL should be triggered after the user inputs their credentials and the token should be retrieved successfully.
Actual Behavior
The callback URL (
/auth/callback
) gets stuck and does not retrieve the token if the user is not already authenticated.Troubleshooting Steps Taken
http://localhost:4444/auth/callback
.Additional Information
Code Snippet
The text was updated successfully, but these errors were encountered: