第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

從 Azure AD Java 獲取訪問(wèn)令牌

從 Azure AD Java 獲取訪問(wèn)令牌

慕標(biāo)5832272 2022-07-20 16:35:23
我想通過(guò) Billing REST Api 獲得 Azure RateCard Json 響應(yīng)。為此,我在 Eclipse 中使用以下代碼:import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.net.HttpURLConnection;import java.net.MalformedURLException;import java.net.URL;import com.fasterxml.jackson.core.JsonFactory;import com.fasterxml.jackson.core.JsonParser;import com.fasterxml.jackson.core.JsonToken;public class RateCardRest {public static String getAccessToken(String tenantId, String clientId, String clientSecret)        throws MalformedURLException, IOException {    String endpoint = String.format("https://login.microsoftonline.com/%s/oauth2/token", tenantId);    String postBody = String.format("grant_type=client_credentials&client_id=%s&client_secret=%s&resource=%s",            clientId, clientSecret, "https://management.azure.com/");    HttpURLConnection conn = (HttpURLConnection) new URL(endpoint).openConnection();    conn.setRequestMethod("POST");    conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded");    conn.setDoOutput(true);    conn.getOutputStream().write(postBody.getBytes());    conn.connect();//      If you want to see the response content, please use the commented code below.//      BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));//      StringBuilder builder = new StringBuilder();//      String line = null;//      while ((line = reader.readLine()) != null) {//          builder.append(line);//      }//      reader.close();//      System.out.println(builder.toString());//      The output for access token is         String name = parser.getCurrentName();        if ("access_token".equals(name)) {            parser.nextToken();            accessToken = parser.getText();        }    }    return accessToken;}當(dāng)我搜索 URL 時(shí),我收到以下消息:AADSTS900561:端點(diǎn)只接受 POST、OPTIONS 請(qǐng)求。收到一個(gè) GET 請(qǐng)求。
查看完整描述

1 回答

?
POPMUISE

TA貢獻(xiàn)1765條經(jīng)驗(yàn) 獲得超5個(gè)贊

您需要對(duì)在 AAD 中生成的客戶端密鑰進(jìn)行 UrlEncode。

http://img1.sycdn.imooc.com//62d7c1050001c5d109630343.jpg

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

下面到

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


查看完整回答
反對(duì) 回復(fù) 2022-07-20
  • 1 回答
  • 0 關(guān)注
  • 109 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)