BrowserStack: Unexpected error. Authorization required BrowserStack: Unexpected error. Authorization required selenium selenium

BrowserStack: Unexpected error. Authorization required


This seems an issue specific to how the selenium language bindings generate payload and how browserstack parses it at their end.

Based on the error message you shared, it is quite likely that while parsing the request payload, browserstack is not able to find your username and access key

You may follow the steps mentioned below to debug this:

  • Change the line driver = new RemoteWebDriver(new Uri("https://hub-cloud.browserstack.com/wd/hub/"), options); to driver = new RemoteWebDriver( new Uri("http://localhost:4444/wd/hub/"), options );. You are not required to start selenium-standalone jar locally.

  • Start a proxy that reads traffic on localhost:4444. (You may use a node based implementation for the same if needed. Here is one such implementation: https://gist.github.com/hanikhan/f817bd64b063129cb78dc7ed0b66fdb7)

  • Observe the request payload generated by the selenium client bindings you are using(v3.14 as you mentioned). For example, my java based selenium client generates this when only browser is passed is desiredcapabitlies {"desiredCapabilities":{"browserName":"Chrome"},"capabilities":{"firstMatch":[{"browserName":"Chrome"}]}}

  • Now downgrade your selenium bindings(to a version where it was working) and observe the payload it generates.

Check if the client bindings use strict checks due to which some required capabilities are getting discarded at your end.

If this is true then you will be required to do one of the following:

  • Raise an issue with selenium C# bindings to remove strict checks for your case
  • Contact Browserstack and ask them to provide a capability that passes the strict check


You can pass the capabilities as below for both Edge and Chrome using EdgeOptions and ChromeOptions to initiate session on BrowserStack. This is in Java. Port your test accordingly for other languages.

For Edge

EdgeOptions options = new EdgeOptions(); options.setCapability("browserstack.user","<userName>"); options.setCapability("browserstack.key","<accessKey>"); options.setCapability("os_version", "10"); //desired os_version options.setCapability("browser", "chrome"); //desired browser driver = new RemoteWebDriver(new URL("https://hub-cloud.browserstack.com/wd/hub"), options);

For Chrome

 ChromeOptions options = new ChromeOptions();    options.setCapability("browserstack.user","<userName>");    options.setCapability("browserstack.key","<accessKey>");    options.setCapability("os_version", "10");    options.setCapability("browser", "chrome");    driver = new RemoteWebDriver(new URL("https://hub-cloud.browserstack.com/wd/hub"), options);


I ran into this same issue and resolved it by setting the "isGlobalCapability" to true on every "AddAdditionalCapability" method for ChromeOptions (using Selenium 3.14). If just one of them doesn't have it set, the test fails.

chromeOptions.AddAdditionalCapability("browserstack.user", <user>, true);chromeOptions.AddAdditionalCapability("browserstack.key", <key>, true);chromeOptions.AddAdditionalCapability("browser", "chrome", true);chromeOptions.AddAdditionalCapability("os", "Windows", true);chromeOptions.AddAdditionalCapability("os_version", "10", true);_Driver = new RemoteWebDriver(new Uri("http://hub-cloud.browserstack.com/wd/hub/"), chromeOptions);