title: AADToken: HTTP connection to https://login.microsoftonline.com/<tenantID>/oauth2/token failed for getting token from AzureAD
body: <p>I want to get access to Azure Data Lake Storage Gen2 from Azure Databricks Cluster - SCALA version, via mount point in filesystem.</p>
  <p>I tried the following code where azure service principal credentials are designated as entry point to azure subscription (role --&gt; storage blob data owner ON Data Lake containers).</p>
  <pre><code>val fileSystemName = &quot;XXXXXXXXXX&quot;
  val storageAccountName = &quot;XXXXXXXXXXXX&quot;
  val appID = &quot;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;
  val appSecret = &quot;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;
  val tenantID = &quot;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&quot;
  
  val configs = Map(
    &quot;fs.azure.account.auth.type&quot; -&gt; &quot;OAuth&quot;,
    &quot;fs.azure.account.oauth.provider.type&quot; -&gt; &quot;org.apache.hadoop.fs.azurebfs.oauth2.ClientCredsTokenProvider&quot;,
    &quot;fs.azure.account.oauth2.client.id&quot; -&gt; &quot;&lt;appID&gt;&quot;,
    &quot;fs.azure.account.oauth2.client.secret&quot; -&gt; &quot;&lt;appSecret&gt;&quot;,
    &quot;fs.azure.account.oauth2.client.endpoint&quot; -&gt; &quot;https://login.microsoftonline.com/&lt;tenantID&gt;/oauth2/token&quot;)
  
  // Optionally, you can add &lt;directory-name&gt; to the source URI of your mount point.
  dbutils.fs.mount(
    source = &quot;abfss://&lt;fileSystemName&gt;@&lt;storageAccountName&gt;.dfs.core.windows.net/&quot;,
    mountPoint = &quot;/mnt/raw-container&quot;,
    extraConfigs = configs)
  </code></pre>
  <p>But get this error message :</p>
  <pre><code>shaded.databricks.v20180920_b33d810.org.apache.hadoop.fs.azurebfs.oauth2.AzureADAuthenticator$HttpException: HTTP Error 400; url='https://login.microsoftonline.com/&lt;tenantID&gt;/oauth2/token' AADToken: HTTP connection to https://login.microsoftonline.com/&lt;tenantID&gt;/oauth2/token failed for getting token from AzureAD.; requestId=''; contentType='text/html; charset=us-ascii'; response '&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot;&quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;
  
  
  &lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;Bad Request&lt;/TITLE&gt;
  &lt;META HTTP-EQUIV=&quot;Content-Type&quot; Content=&quot;text/html; charset=us-ascii&quot;&gt;&lt;/HEAD&gt;
  &lt;BODY&gt;&lt;h2&gt;Bad Request - Invalid URL&lt;/h2&gt;
  &lt;hr&gt;&lt;p&gt;HTTP Error 400. The request URL is invalid.&lt;/p&gt;
  &lt;/BODY&gt;&lt;/HTML&gt;
  '
      at shaded.databricks.v20180920_b33d810.org.apache.hadoop.fs.azurebfs.oauth2.AzureADAuthenticator.getTokenSingleCall(AzureADAuthenticator.java:372)
      at shaded.databricks.v20180920_b33d810.org.apache.hadoop.fs.azurebfs.oauth2.AzureADAuthenticator.getTokenCall(AzureADAuthenticator.java:270)
      at shaded.databricks.v20180920_b33d810.org.apache.hadoop.fs.azurebfs.oauth2.AzureADAuthenticator.getTokenUsingClientCreds(AzureADAuthenticator.java:95)
      at com.databricks.backend.daemon.dbutils.DBUtilsCore.verifyAzureOAuth(DBUtilsCore.scala:477)
      at com.databricks.backend.daemon.dbutils.DBUtilsCore.verifyAzureFileSystem(DBUtilsCore.scala:488)
      at com.databricks.backend.daemon.dbutils.DBUtilsCore.mount(DBUtilsCore.scala:446)
      at com.databricks.dbutils_v1.impl.DbfsUtilsImpl.mount(DbfsUtilsImpl.scala:85)
      at linec1d28633ab4c4f2d9530ae7396d8282327.$read$$iw$$iw$$iw$$iw$$iw$$iw.&lt;init&gt;(command-3300122855614219:18)
      at linec1d28633ab4c4f2d9530ae7396d8282327.$read$$iw$$iw$$iw$$iw$$iw.&lt;init&gt;(command-3300122855614219:67)
      at linec1d28633ab4c4f2d9530ae7396d8282327.$read$$iw$$iw$$iw$$iw.&lt;init&gt;(command-3300122855614219:69)
      at linec1d28633ab4c4f2d9530ae7396d8282327.$read$$iw$$iw$$iw.&lt;init&gt;(command-3300122855614219:71)
      at linec1d28633ab4c4f2d9530ae7396d8282327.$read$$iw$$iw.&lt;init&gt;(command-3300122855614219:73)
      at linec1d28633ab4c4f2d9530ae7396d8282327.$read$$iw.&lt;init&gt;(command-3300122855614219:75)
      at linec1d28633ab4c4f2d9530ae7396d8282327.$read.&lt;init&gt;(command-3300122855614219:77)
      at linec1d28633ab4c4f2d9530ae7396d8282327.$read$.&lt;init&gt;(command-3300122855614219:81)
      at linec1d28633ab4c4f2d9530ae7396d8282327.$read$.&lt;clinit&gt;(command-3300122855614219)
      at linec1d28633ab4c4f2d9530ae7396d8282327.$eval$.$print$lzycompute(&lt;notebook&gt;:7)
      at linec1d28633ab4c4f2d9530ae7396d8282327.$eval$.$print(&lt;notebook&gt;:6)
      at linec1d28633ab4c4f2d9530ae7396d8282327.$eval.$print(&lt;notebook&gt;)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.call(IMain.scala:745)
      at scala.tools.nsc.interpreter.IMain$Request.loadAndRun(IMain.scala:1021)
      at scala.tools.nsc.interpreter.IMain.$anonfun$interpret$1(IMain.scala:574)
      at scala.reflect.internal.util.ScalaClassLoader.asContext(ScalaClassLoader.scala:41)
      at scala.reflect.internal.util.ScalaClassLoader.asContext$(ScalaClassLoader.scala:37)
      at scala.reflect.internal.util.AbstractFileClassLoader.asContext(AbstractFileClassLoader.scala:41)
      at scala.tools.nsc.interpreter.IMain.loadAndRunReq$1(IMain.scala:573)
      at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:600)
      at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:570)
      at com.databricks.backend.daemon.driver.DriverILoop.execute(DriverILoop.scala:215)
      at com.databricks.backend.daemon.driver.ScalaDriverLocal.$anonfun$repl$1(ScalaDriverLocal.scala:202)
      at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
      at com.databricks.backend.daemon.driver.DriverLocal$TrapExitInternal$.trapExit(DriverLocal.scala:714)
      at com.databricks.backend.daemon.driver.DriverLocal$TrapExit$.apply(DriverLocal.scala:667)
      at com.databricks.backend.daemon.driver.ScalaDriverLocal.repl(ScalaDriverLocal.scala:202)
      at com.databricks.backend.daemon.driver.DriverLocal.$anonfun$execute$10(DriverLocal.scala:396)
      at com.databricks.logging.UsageLogging.$anonfun$withAttributionContext$1(UsageLogging.scala:238)
      at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
      at com.databricks.logging.UsageLogging.withAttributionContext(UsageLogging.scala:233)
      at com.databricks.logging.UsageLogging.withAttributionContext$(UsageLogging.scala:230)
      at com.databricks.backend.daemon.driver.DriverLocal.withAttributionContext(DriverLocal.scala:49)
      at com.databricks.logging.UsageLogging.withAttributionTags(UsageLogging.scala:275)
      at com.databricks.logging.UsageLogging.withAttributionTags$(UsageLogging.scala:268)
      at com.databricks.backend.daemon.driver.DriverLocal.withAttributionTags(DriverLocal.scala:49)
      at com.databricks.backend.daemon.driver.DriverLocal.execute(DriverLocal.scala:373)
      at com.databricks.backend.daemon.driver.DriverWrapper.$anonfun$tryExecutingCommand$1(DriverWrapper.scala:653)
      at scala.util.Try$.apply(Try.scala:213)
      at com.databricks.backend.daemon.driver.DriverWrapper.tryExecutingCommand(DriverWrapper.scala:645)
      at com.databricks.backend.daemon.driver.DriverWrapper.getCommandOutputAndError(DriverWrapper.scala:486)
      at com.databricks.backend.daemon.driver.DriverWrapper.executeCommand(DriverWrapper.scala:598)
      at com.databricks.backend.daemon.driver.DriverWrapper.runInnerLoop(DriverWrapper.scala:391)
      at com.databricks.backend.daemon.driver.DriverWrapper.runInner(DriverWrapper.scala:337)
      at com.databricks.backend.daemon.driver.DriverWrapper.run(DriverWrapper.scala:219)
      at java.lang.Thread.run(Thread.java:748)
  </code></pre>
  <p>It seems there is an endpoint authentication issue.</p>
  <hr />
  <p><strong>If the question helped, up-vote it. Thanks in advance.</strong></p>