Home » Angularjs » I'm providing 'sauceUser' and 'sauceKey' in my config yet sauce says I'm trying to authenticate with username 'None' and access key 'None'

I'm providing 'sauceUser' and 'sauceKey' in my config yet sauce says I'm trying to authenticate with username 'None' and access key 'None'

Posted by: admin January 30, 2018 Leave a comment

Questions:

I’m trying to test a mobile app written using Ionic and since Ionic is based on Angular, I want to write tests using Protractor and run the tests in mobile emulators using Saucelabs Appium. I invoke protractor using the command:

SAUCE_USERNAME=$(SAUCE_USERNAME) SAUCE_ACCESS_KEY=$(SAUCE_ACCESS_KEY) ./node_modules/.bin/protractor protractorConfig.js

But I get the following error:

UnknownError: Sauce Labs Authentication Error.
You used username 'None' and access key 'None' to authenticate, which are not valid Sauce Labs credentials.

My protractorConfig.js contains:

/* global exports */
/* global process */
exports.config = {
  sauceUser: process.env.SAUCE_USERNAME,
  sauceKey: process.env.SAUCE_ACCESS_KEY,
  capabilities: {
    appiumVersion: "1.0",
    app: "sauce-storage:app.zip",
    platformName: "iOS",
    platformVersion: "7.1",
    deviceName: "iPhone Simulator",
    browserName: ""
  },
  allScriptsTimeout: 30000,
  seleniumAddress: "http://" + 
    process.env.SAUCE_USERNAME + ":"+process.env.SAUCE_ACCESS_KEY+
    "@ondemand.saucelabs.com:80/wd/hub",

  specs: [
    "spec/feature/*.js"
  ]
};

Why is Protractor/Saucelabs saying I’m not providing a user name or access key?

Edit: I based this question and my answer from information in one of the answers in Running e2e tests on Sauce Labs from Protractor on Travis. I made this question and answer in hopes that the information, which took a lot of google searching to find, would be more accessible to others who have the same issue.

Answers:

Thanks to this other question I now know that you have to omit the ‘seleniumAddress’ from the configuration, otherwise Protractor will ignore your Saucelabs authentication. It will correctly generate the ‘seleniumAddress’ if omitted, though at this point I’m not sure how it knows how to do that.