从Azure AD Java获取访问令牌

时间:2019-03-06 07:41:39

标签: java eclipse rest azure api

我想通过Billing REST Api获得Azure RateCard Json响应。 为此,我在eclipse中使用以下代码:

body {
  position: fixed;
  display: flex;
  flex-direction: column;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  overflow: hidden;
}

section {
  height: 600px;
  border: 2px solid white;
  background: blue;
}

section:nth-child(2) {
  background: red;
}

.container {
  flex: 1;
  display: flex;
  position: relative;
  flex-direction: column;
  overflow: auto;
}

.long {
  height: 1200px;
}

.header {
  height: 75px;
  background: green;
}

.hero {
  background: silver;
  flex: 0;
  border: 1px solid;
}

.nav {
  background: white;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.nav--top {
  position: fixed;
  top: 75px;
}

.sticky {
  background: white;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  position: relative;
}

.tab {
  padding: 30px 45px;
  position: relative;
}

.tab.active {
  background: #6567c5;
  color: white;
}

这会导致以下错误:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="header">
  <h1>Header</h1>
</div>
<div class="container">
  <div class="hero">
    <h1>Hero</h1>
  </div>
  <div class="sticky">
    <nav role="navigation" class="nav">
      <a class="tab" href="#One">Option One</a>
      <a class="tab" href="#Two">Option Two</a>
    </nav>
  </div>
  <div class="main">
    <section id="One">
    </section>
    <section class="long" id="Two">
    </section>
  </div>
</div>
</div>

搜索URL时,出现以下消息:

AADSTS900561:端点仅接受POST,OPTIONS请求。收到了GET请求。

希望有人可以帮助我。 在此先感谢!

1 个答案:

答案 0 :(得分:1)

您需要对AAD中生成的客户端密钥进行UrlEncode。

enter image description here 添加

clientSecret=java.net.URLEncoder.encode(clientSecret,"UTF-8");

低于

String clientSecret = "<your client secret key generated in AAD>";