Basic Authentication issue

  • 19 October 2020
  • 2 replies
  • 386 views

I am using Basic Authentication for my app. And I need to display login errors if they provide wrong credentials.. So how can i achieve this? Now what is happening, simply the login window gets disappeared after submit.Thank you


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +9

For Basic auth, you’ll want to handle incorrect credentials in the response handling of your Test request.  

 

If you’re developing in the UI, switch to code mode and add code similar to this in the response handling.  Be sure to check for the error or error codes your api actually returns:

 

  if (response.status === 401) {
throw new z.errors.Error(
// This message is surfaced to the user
'The username and/or password you supplied is incorrect',
'AuthenticationError',
response.status
);
}

return response;

If you’re using the CLI, heres a very simple, but complete, example: https://github.com/zapier/zapier-platform/tree/master/example-apps/basic-auth

Ya its working.. Thanks Zane..