mucsi96 / nightwatch-api

[DEPRECATED] Cross-runner API for Nightwatch.js
https://nightwatch-api.netlify.com/
MIT License
84 stars 64 forks source link

Need help with using Basic authentication #379

Closed aks87 closed 5 years ago

aks87 commented 5 years ago

Hello Everyone,

I have spent lot of time in trying to get basic authentication work with nightwatch-api and cucumber. Could someone please advice and share their thoughts?

Thank you for your time.

DmytroShtanko1 commented 5 years ago

Oh, there are you have registration API. You need to fill up the required fields and send them. After you will get authorization token. You will use this token for another requests to the system in headers.

On Tue, Apr 9, 2019, 00:40 aks87 notifications@github.com wrote:

Hello Everyone,

I have spent lot of time in trying to get basic authentication work with nightwatch-api and cucumber. Could someone please advice and share their thoughts?

Thank you for your time.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mucsi96/nightwatch-api/issues/379, or mute the thread https://github.com/notifications/unsubscribe-auth/AVmGWFluv87aUBLO5O6B-Zn1Z_KSz5nCks5ve7dpgaJpZM4cjKxs .

aks87 commented 5 years ago

@DmytroShtanko1 - Thank you for your prompt response.

Could you please give an example?

To elaborate my question, following are the approaches I have tried but didn't work for basic authentication:

1) Adding username and access_key in nightwatch.conf.js (highlighted in bold). ..... .... test_settings: { default: { username: 'test', access_key: 'testPass', selenium: { start_process: true, server_path: seleniumServer.path, port: 4444, cli_args: { 'webdriver.chrome.driver': chromeDriver.path, 'webdriver.gecko.driver': geckoDriver.path, 'webdriver.ie.driver': ieDriver.path, 'webdriver.edge.driver': edgeDriver.path }, } } ... ...

2) Tried including the credentials in the url (highlighted in bold).

 client.url('http://**test:testPass**@localhost:7787/testPage.html');

Please let me know your inputs. Thank you for your time.

spnraju commented 5 years ago

Hi @aks87 are you talking about passing on the username and password while logging into your application through automation?

If so, the simplest way I could suggest is add them to your environment variables and you can use them using process.env.username.

This has nothing to do with repo and this is also not the place to ask for help. Closing this for now but you can let me know if that did not work. If you have the project on github that would be great.

aks87 commented 5 years ago

@spnraju - Yes, I am trying to get basic authentication work in my application via automation

spnraju commented 5 years ago

@aks87 You can refer to the below links.

https://github.com/nightwatchjs/nightwatch/issues/498 https://dev.to/deammer/loading-environment-variables-in-js-apps-1p7p https://medium.com/appstract/environment-variables-in-javascript-with-laravel-elixir-593df994d765