Azure RateCard “AuthenticationFailed”"bufferReader or InputStreamReader always throws exceptionWhat is the difference between an Azure Web Site and an Azure Web RoleAuthenticationFailed Azure Table StorageJava - HashMap and HashSet not backed by Object.hashCode()?AuthenticationFailed with Azure node.js SDK's createContainerIfNotExist methodHow to get the azure account tenant Id?Need to parse a value from other webpage. First I need to call other webpage and parse the XML value from itAzure CLI - Get RateCard InformationAuthorize Azure AD application to access RateCard APIAzure Storage SAS AuthenticationFailed

How can I use the arrow sign in my bash prompt?

Is exact Kanji stroke length important?

Why Were Madagascar and New Zealand Discovered So Late?

What are the ramifications of creating a homebrew world without an Astral Plane?

How could Frankenstein get the parts for his _second_ creature?

Is it correct to write "is not focus on"?

Can somebody explain Brexit in a few child-proof sentences?

Greatest common substring

apt-get update is failing in debian

There is only s̶i̶x̶t̶y one place he can be

Personal Teleportation as a Weapon

Do I need a multiple entry visa for a trip UK -> Sweden -> UK?

Hostile work environment after whistle-blowing on coworker and our boss. What do I do?

The baby cries all morning

Can a monster with multiattack use this ability if they are missing a limb?

Is there any reason not to eat food that's been dropped on the surface of the moon?

Ways to speed up user implemented RK4

What would happen if the UK refused to take part in EU Parliamentary elections?

Can I Retrieve Email Addresses from BCC?

Short story about space worker geeks who zone out by 'listening' to radiation from stars

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

Opposite of a diet

Is this Spell Mimic feat balanced?

Curses work by shouting - How to avoid collateral damage?



Azure RateCard “AuthenticationFailed”"


bufferReader or InputStreamReader always throws exceptionWhat is the difference between an Azure Web Site and an Azure Web RoleAuthenticationFailed Azure Table StorageJava - HashMap and HashSet not backed by Object.hashCode()?AuthenticationFailed with Azure node.js SDK's createContainerIfNotExist methodHow to get the azure account tenant Id?Need to parse a value from other webpage. First I need to call other webpage and parse the XML value from itAzure CLI - Get RateCard InformationAuthorize Azure AD application to access RateCard APIAzure Storage SAS AuthenticationFailed













0















I want to get a Azure RateCard via Billing Api with a Java Application.
First of all I create an AccessToken what works correctly. But when I want to use this AccessToken to get a RateCard I get an authentication error.
Here is my java code:



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 TestingAzure

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 "token_type":"Bearer","expires_in":"3600","ext_expires_in":"3600","expires_on":"1550660092","not_before":"1550656192","resource":"https://management.azure.com/","access_token":"eyJ0eXAiOiJKV1QiL...."
JsonFactory factory = new JsonFactory();
JsonParser parser = factory.createParser(conn.getInputStream());
String accessToken = null;
while (parser.nextToken() != JsonToken.END_OBJECT)
String name = parser.getCurrentName();
if ("access_token".equals(name))
parser.nextToken();
accessToken = parser.getText();


return accessToken;


public static String getRateCard(String subscriptionId, String apiVersion, String offerId, String currency,
String locale, String region, String accessToken) throws MalformedURLException, IOException
String endpoint = String.format(
"https://management.azure.com/subscriptions/%s/providers/Microsoft.Commerce/RateCard?api-version=%s&$filter=OfferDurableId eq '%s' and Currency eq '%s' and Locale eq '%s' and RegionInfo eq '%s'",
subscriptionId, apiVersion, offerId, currency, locale, region).replaceAll(" ", "%20");
HttpURLConnection conn = (HttpURLConnection) new URL(endpoint).openConnection();
conn.setRequestMethod("GET");
conn.addRequestProperty("Authorization", "Bearer " + accessToken);
conn.addRequestProperty("Content-Type", "application/json");
conn.connect();
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();
return builder.toString();


public static void main(String[] args) throws MalformedURLException, IOException
String tenantId = "*****";
String clientId = "*****";
String clientSecret = "*****";
clientSecret=java.net.URLEncoder.encode(clientSecret,"UTF-8");
System.out.println(clientSecret);
String accessToken = getAccessToken(tenantId, clientId, clientSecret);
System.out.println(accessToken);
String subscriptionId = "*****";
String apiVersion = "2015-06-01-preview";
String offerId = "****";
String currency = "EUR";
String locale = "de-DE";
String region = "DE";
String rateCardResp = getRateCard(subscriptionId, apiVersion, offerId, currency, locale, region, accessToken);
System.out.println(rateCardResp);





In Eclipse the error is:



Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://management.azure.com/subscriptions/*subscriptionID*/providers/Microsoft.Commerce/RateCard?api-version=2015-06-01-preview&$filter=OfferDurableId%20eq%20'MS-AZR-0017P'%20and%20Currency%20eq%20'EUR'%20and%20Locale%20eq%20'de-DE'%20and%20RegionInfo%20eq%20'DE'
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
at com.nttdata.altemista.TestingAzure.getRateCard(TestingAzure.java:60)
at com.nttdata.altemista.TestingAzure.main(TestingAzure.java:84)


When I search for the URL I get the following message:



"error":"code":"AuthenticationFailed","message":"Fehler bei der Authentifizierung. Der Authorization-Header fehlt."


Actually I had the highest role to work with this subscription. I don't know what I can try.










share|improve this question


























    0















    I want to get a Azure RateCard via Billing Api with a Java Application.
    First of all I create an AccessToken what works correctly. But when I want to use this AccessToken to get a RateCard I get an authentication error.
    Here is my java code:



    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 TestingAzure

    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 "token_type":"Bearer","expires_in":"3600","ext_expires_in":"3600","expires_on":"1550660092","not_before":"1550656192","resource":"https://management.azure.com/","access_token":"eyJ0eXAiOiJKV1QiL...."
    JsonFactory factory = new JsonFactory();
    JsonParser parser = factory.createParser(conn.getInputStream());
    String accessToken = null;
    while (parser.nextToken() != JsonToken.END_OBJECT)
    String name = parser.getCurrentName();
    if ("access_token".equals(name))
    parser.nextToken();
    accessToken = parser.getText();


    return accessToken;


    public static String getRateCard(String subscriptionId, String apiVersion, String offerId, String currency,
    String locale, String region, String accessToken) throws MalformedURLException, IOException
    String endpoint = String.format(
    "https://management.azure.com/subscriptions/%s/providers/Microsoft.Commerce/RateCard?api-version=%s&$filter=OfferDurableId eq '%s' and Currency eq '%s' and Locale eq '%s' and RegionInfo eq '%s'",
    subscriptionId, apiVersion, offerId, currency, locale, region).replaceAll(" ", "%20");
    HttpURLConnection conn = (HttpURLConnection) new URL(endpoint).openConnection();
    conn.setRequestMethod("GET");
    conn.addRequestProperty("Authorization", "Bearer " + accessToken);
    conn.addRequestProperty("Content-Type", "application/json");
    conn.connect();
    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();
    return builder.toString();


    public static void main(String[] args) throws MalformedURLException, IOException
    String tenantId = "*****";
    String clientId = "*****";
    String clientSecret = "*****";
    clientSecret=java.net.URLEncoder.encode(clientSecret,"UTF-8");
    System.out.println(clientSecret);
    String accessToken = getAccessToken(tenantId, clientId, clientSecret);
    System.out.println(accessToken);
    String subscriptionId = "*****";
    String apiVersion = "2015-06-01-preview";
    String offerId = "****";
    String currency = "EUR";
    String locale = "de-DE";
    String region = "DE";
    String rateCardResp = getRateCard(subscriptionId, apiVersion, offerId, currency, locale, region, accessToken);
    System.out.println(rateCardResp);





    In Eclipse the error is:



    Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://management.azure.com/subscriptions/*subscriptionID*/providers/Microsoft.Commerce/RateCard?api-version=2015-06-01-preview&$filter=OfferDurableId%20eq%20'MS-AZR-0017P'%20and%20Currency%20eq%20'EUR'%20and%20Locale%20eq%20'de-DE'%20and%20RegionInfo%20eq%20'DE'
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
    at com.nttdata.altemista.TestingAzure.getRateCard(TestingAzure.java:60)
    at com.nttdata.altemista.TestingAzure.main(TestingAzure.java:84)


    When I search for the URL I get the following message:



    "error":"code":"AuthenticationFailed","message":"Fehler bei der Authentifizierung. Der Authorization-Header fehlt."


    Actually I had the highest role to work with this subscription. I don't know what I can try.










    share|improve this question
























      0












      0








      0








      I want to get a Azure RateCard via Billing Api with a Java Application.
      First of all I create an AccessToken what works correctly. But when I want to use this AccessToken to get a RateCard I get an authentication error.
      Here is my java code:



      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 TestingAzure

      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 "token_type":"Bearer","expires_in":"3600","ext_expires_in":"3600","expires_on":"1550660092","not_before":"1550656192","resource":"https://management.azure.com/","access_token":"eyJ0eXAiOiJKV1QiL...."
      JsonFactory factory = new JsonFactory();
      JsonParser parser = factory.createParser(conn.getInputStream());
      String accessToken = null;
      while (parser.nextToken() != JsonToken.END_OBJECT)
      String name = parser.getCurrentName();
      if ("access_token".equals(name))
      parser.nextToken();
      accessToken = parser.getText();


      return accessToken;


      public static String getRateCard(String subscriptionId, String apiVersion, String offerId, String currency,
      String locale, String region, String accessToken) throws MalformedURLException, IOException
      String endpoint = String.format(
      "https://management.azure.com/subscriptions/%s/providers/Microsoft.Commerce/RateCard?api-version=%s&$filter=OfferDurableId eq '%s' and Currency eq '%s' and Locale eq '%s' and RegionInfo eq '%s'",
      subscriptionId, apiVersion, offerId, currency, locale, region).replaceAll(" ", "%20");
      HttpURLConnection conn = (HttpURLConnection) new URL(endpoint).openConnection();
      conn.setRequestMethod("GET");
      conn.addRequestProperty("Authorization", "Bearer " + accessToken);
      conn.addRequestProperty("Content-Type", "application/json");
      conn.connect();
      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();
      return builder.toString();


      public static void main(String[] args) throws MalformedURLException, IOException
      String tenantId = "*****";
      String clientId = "*****";
      String clientSecret = "*****";
      clientSecret=java.net.URLEncoder.encode(clientSecret,"UTF-8");
      System.out.println(clientSecret);
      String accessToken = getAccessToken(tenantId, clientId, clientSecret);
      System.out.println(accessToken);
      String subscriptionId = "*****";
      String apiVersion = "2015-06-01-preview";
      String offerId = "****";
      String currency = "EUR";
      String locale = "de-DE";
      String region = "DE";
      String rateCardResp = getRateCard(subscriptionId, apiVersion, offerId, currency, locale, region, accessToken);
      System.out.println(rateCardResp);





      In Eclipse the error is:



      Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://management.azure.com/subscriptions/*subscriptionID*/providers/Microsoft.Commerce/RateCard?api-version=2015-06-01-preview&$filter=OfferDurableId%20eq%20'MS-AZR-0017P'%20and%20Currency%20eq%20'EUR'%20and%20Locale%20eq%20'de-DE'%20and%20RegionInfo%20eq%20'DE'
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
      at com.nttdata.altemista.TestingAzure.getRateCard(TestingAzure.java:60)
      at com.nttdata.altemista.TestingAzure.main(TestingAzure.java:84)


      When I search for the URL I get the following message:



      "error":"code":"AuthenticationFailed","message":"Fehler bei der Authentifizierung. Der Authorization-Header fehlt."


      Actually I had the highest role to work with this subscription. I don't know what I can try.










      share|improve this question














      I want to get a Azure RateCard via Billing Api with a Java Application.
      First of all I create an AccessToken what works correctly. But when I want to use this AccessToken to get a RateCard I get an authentication error.
      Here is my java code:



      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 TestingAzure

      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 "token_type":"Bearer","expires_in":"3600","ext_expires_in":"3600","expires_on":"1550660092","not_before":"1550656192","resource":"https://management.azure.com/","access_token":"eyJ0eXAiOiJKV1QiL...."
      JsonFactory factory = new JsonFactory();
      JsonParser parser = factory.createParser(conn.getInputStream());
      String accessToken = null;
      while (parser.nextToken() != JsonToken.END_OBJECT)
      String name = parser.getCurrentName();
      if ("access_token".equals(name))
      parser.nextToken();
      accessToken = parser.getText();


      return accessToken;


      public static String getRateCard(String subscriptionId, String apiVersion, String offerId, String currency,
      String locale, String region, String accessToken) throws MalformedURLException, IOException
      String endpoint = String.format(
      "https://management.azure.com/subscriptions/%s/providers/Microsoft.Commerce/RateCard?api-version=%s&$filter=OfferDurableId eq '%s' and Currency eq '%s' and Locale eq '%s' and RegionInfo eq '%s'",
      subscriptionId, apiVersion, offerId, currency, locale, region).replaceAll(" ", "%20");
      HttpURLConnection conn = (HttpURLConnection) new URL(endpoint).openConnection();
      conn.setRequestMethod("GET");
      conn.addRequestProperty("Authorization", "Bearer " + accessToken);
      conn.addRequestProperty("Content-Type", "application/json");
      conn.connect();
      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();
      return builder.toString();


      public static void main(String[] args) throws MalformedURLException, IOException
      String tenantId = "*****";
      String clientId = "*****";
      String clientSecret = "*****";
      clientSecret=java.net.URLEncoder.encode(clientSecret,"UTF-8");
      System.out.println(clientSecret);
      String accessToken = getAccessToken(tenantId, clientId, clientSecret);
      System.out.println(accessToken);
      String subscriptionId = "*****";
      String apiVersion = "2015-06-01-preview";
      String offerId = "****";
      String currency = "EUR";
      String locale = "de-DE";
      String region = "DE";
      String rateCardResp = getRateCard(subscriptionId, apiVersion, offerId, currency, locale, region, accessToken);
      System.out.println(rateCardResp);





      In Eclipse the error is:



      Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://management.azure.com/subscriptions/*subscriptionID*/providers/Microsoft.Commerce/RateCard?api-version=2015-06-01-preview&$filter=OfferDurableId%20eq%20'MS-AZR-0017P'%20and%20Currency%20eq%20'EUR'%20and%20Locale%20eq%20'de-DE'%20and%20RegionInfo%20eq%20'DE'
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
      at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
      at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source)
      at com.nttdata.altemista.TestingAzure.getRateCard(TestingAzure.java:60)
      at com.nttdata.altemista.TestingAzure.main(TestingAzure.java:84)


      When I search for the URL I get the following message:



      "error":"code":"AuthenticationFailed","message":"Fehler bei der Authentifizierung. Der Authorization-Header fehlt."


      Actually I had the highest role to work with this subscription. I don't know what I can try.







      java eclipse azure api






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 11:50









      WuldWuld

      216




      216






















          1 Answer
          1






          active

          oldest

          votes


















          0














          In your sample , Have you given sufficent permission to your service principal, which is permission to access Windows Azure Service Management APIs.



          Here is very good example , how to configure an app in Azure AD if you want to access management resources in Java



          https://blogs.msdn.microsoft.com/azureossds/2015/06/23/authenticating-azure-resource-management-rest-api-requests-using-java/



          Alternatively , Here is how you can configure the native app to use the Azure Rate card Api
          Step 1: Configure a Native Client application in your AAD tenant



          Before you can run the sample application, you will need to allow it to access your AAD tenant for authentication and authorization to access the Billing APIs. If you already have a Native Client Application configured that you would like to use (and it is configured according to the steps below), you can jump to Step 2.



          To configure a new AAD application:



          1. Sign in to the Azure portal, using credentials that have been granted service administrator/co-administrator access on the subscription which is trusting your AAD tenant, and granted Global Administrator access in the AAD tenant. See Manage Accounts, Subscriptions, and Administrative Roles for details on managing the service administrator and co-administrators.


          2. Select the AAD tenant you wish to use, and go to the "Applications" page.


          3. From there, you can use the "Add" feature to "Add a new application my organization is developing".


          4. Provide a name (ie: ConsoleApp-Billing-RateCard or similar) for the new application.


          5. Be sure to select the "Native Client Application" type, then specify a valid URL for "Redirect URI" (which can be http://localhost/ for the purposes of this sample), and click the check mark to save.


          6. After you've added the new application, select it again within the list of applications and click "Configure" so you can make sure the sample app will have permissions to access the Windows Azure Service Management APIs, which is the permission used to secure the Billing APIs.


          7. Scroll down to the to the "Permissions to other applications" section of your newly created application's configuration page. Then click the "Add Application" button, select the "Windows Azure Service Management" row, and click the check mark to save. After saving, hover the "Delegated Permissions" area on the right side of the "Windows Azure Service Management" row, click the "Delegated Permissions" drop down list, select the "Access Azure Service Management (preview)" option, and click "Save" again.


          NOTE: the "Windows Azure Active Directory" permission "Enable sign-on and read users' profiles" is enabled by default. It allows users to sign in to the application with their organizational accounts, enabling the application to read the profiles of signed-in users, such as their email address and contact information. This is a delegation permission, and gives the user the ability to consent before proceeding. Please refer to Adding, Updating, and Removing an Application for more depth on configuring an Azure AD tenant to enable an application to access your tenant.



          1. While you are on this page, also note/copy the "Client ID" GUID and "Redirect URI",

          as you will use these in Step #3 below. You will also need your Azure Subscription ID and AAD tenant domain name, both of which you can copy from the "Settings" page in the management portal.



          Note:- If you want to use grant_type="Client_credential" and using client id and client_secret, Please ensure you have at least admin/co admin role in the subscription and you application have sufficient permission as mentioned above.






          share|improve this answer

























          • Thank you! I added "Windows Azure Service Management" to the application but unfortunately I get the same error.

            – Wuld
            Mar 11 at 13:23











          • Have you followed the blog i posted above in my answer?

            – Mohit Verma - MSFT
            Mar 11 at 13:26











          • Yeah, but it is not the problem to generate an AccessToken. That works fine.

            – Wuld
            Mar 11 at 13:43











          • Status code 403 is for forbidden only which means token generated from your service principal doesn't have the right level of permission. Might be possible that you are getting token as your app might have the access to windows azure directory, but that doesn't mean that you will be bale to call management api.

            – Mohit Verma - MSFT
            Mar 11 at 13:51










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55043117%2fazure-ratecard-authenticationfailed%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          In your sample , Have you given sufficent permission to your service principal, which is permission to access Windows Azure Service Management APIs.



          Here is very good example , how to configure an app in Azure AD if you want to access management resources in Java



          https://blogs.msdn.microsoft.com/azureossds/2015/06/23/authenticating-azure-resource-management-rest-api-requests-using-java/



          Alternatively , Here is how you can configure the native app to use the Azure Rate card Api
          Step 1: Configure a Native Client application in your AAD tenant



          Before you can run the sample application, you will need to allow it to access your AAD tenant for authentication and authorization to access the Billing APIs. If you already have a Native Client Application configured that you would like to use (and it is configured according to the steps below), you can jump to Step 2.



          To configure a new AAD application:



          1. Sign in to the Azure portal, using credentials that have been granted service administrator/co-administrator access on the subscription which is trusting your AAD tenant, and granted Global Administrator access in the AAD tenant. See Manage Accounts, Subscriptions, and Administrative Roles for details on managing the service administrator and co-administrators.


          2. Select the AAD tenant you wish to use, and go to the "Applications" page.


          3. From there, you can use the "Add" feature to "Add a new application my organization is developing".


          4. Provide a name (ie: ConsoleApp-Billing-RateCard or similar) for the new application.


          5. Be sure to select the "Native Client Application" type, then specify a valid URL for "Redirect URI" (which can be http://localhost/ for the purposes of this sample), and click the check mark to save.


          6. After you've added the new application, select it again within the list of applications and click "Configure" so you can make sure the sample app will have permissions to access the Windows Azure Service Management APIs, which is the permission used to secure the Billing APIs.


          7. Scroll down to the to the "Permissions to other applications" section of your newly created application's configuration page. Then click the "Add Application" button, select the "Windows Azure Service Management" row, and click the check mark to save. After saving, hover the "Delegated Permissions" area on the right side of the "Windows Azure Service Management" row, click the "Delegated Permissions" drop down list, select the "Access Azure Service Management (preview)" option, and click "Save" again.


          NOTE: the "Windows Azure Active Directory" permission "Enable sign-on and read users' profiles" is enabled by default. It allows users to sign in to the application with their organizational accounts, enabling the application to read the profiles of signed-in users, such as their email address and contact information. This is a delegation permission, and gives the user the ability to consent before proceeding. Please refer to Adding, Updating, and Removing an Application for more depth on configuring an Azure AD tenant to enable an application to access your tenant.



          1. While you are on this page, also note/copy the "Client ID" GUID and "Redirect URI",

          as you will use these in Step #3 below. You will also need your Azure Subscription ID and AAD tenant domain name, both of which you can copy from the "Settings" page in the management portal.



          Note:- If you want to use grant_type="Client_credential" and using client id and client_secret, Please ensure you have at least admin/co admin role in the subscription and you application have sufficient permission as mentioned above.






          share|improve this answer

























          • Thank you! I added "Windows Azure Service Management" to the application but unfortunately I get the same error.

            – Wuld
            Mar 11 at 13:23











          • Have you followed the blog i posted above in my answer?

            – Mohit Verma - MSFT
            Mar 11 at 13:26











          • Yeah, but it is not the problem to generate an AccessToken. That works fine.

            – Wuld
            Mar 11 at 13:43











          • Status code 403 is for forbidden only which means token generated from your service principal doesn't have the right level of permission. Might be possible that you are getting token as your app might have the access to windows azure directory, but that doesn't mean that you will be bale to call management api.

            – Mohit Verma - MSFT
            Mar 11 at 13:51















          0














          In your sample , Have you given sufficent permission to your service principal, which is permission to access Windows Azure Service Management APIs.



          Here is very good example , how to configure an app in Azure AD if you want to access management resources in Java



          https://blogs.msdn.microsoft.com/azureossds/2015/06/23/authenticating-azure-resource-management-rest-api-requests-using-java/



          Alternatively , Here is how you can configure the native app to use the Azure Rate card Api
          Step 1: Configure a Native Client application in your AAD tenant



          Before you can run the sample application, you will need to allow it to access your AAD tenant for authentication and authorization to access the Billing APIs. If you already have a Native Client Application configured that you would like to use (and it is configured according to the steps below), you can jump to Step 2.



          To configure a new AAD application:



          1. Sign in to the Azure portal, using credentials that have been granted service administrator/co-administrator access on the subscription which is trusting your AAD tenant, and granted Global Administrator access in the AAD tenant. See Manage Accounts, Subscriptions, and Administrative Roles for details on managing the service administrator and co-administrators.


          2. Select the AAD tenant you wish to use, and go to the "Applications" page.


          3. From there, you can use the "Add" feature to "Add a new application my organization is developing".


          4. Provide a name (ie: ConsoleApp-Billing-RateCard or similar) for the new application.


          5. Be sure to select the "Native Client Application" type, then specify a valid URL for "Redirect URI" (which can be http://localhost/ for the purposes of this sample), and click the check mark to save.


          6. After you've added the new application, select it again within the list of applications and click "Configure" so you can make sure the sample app will have permissions to access the Windows Azure Service Management APIs, which is the permission used to secure the Billing APIs.


          7. Scroll down to the to the "Permissions to other applications" section of your newly created application's configuration page. Then click the "Add Application" button, select the "Windows Azure Service Management" row, and click the check mark to save. After saving, hover the "Delegated Permissions" area on the right side of the "Windows Azure Service Management" row, click the "Delegated Permissions" drop down list, select the "Access Azure Service Management (preview)" option, and click "Save" again.


          NOTE: the "Windows Azure Active Directory" permission "Enable sign-on and read users' profiles" is enabled by default. It allows users to sign in to the application with their organizational accounts, enabling the application to read the profiles of signed-in users, such as their email address and contact information. This is a delegation permission, and gives the user the ability to consent before proceeding. Please refer to Adding, Updating, and Removing an Application for more depth on configuring an Azure AD tenant to enable an application to access your tenant.



          1. While you are on this page, also note/copy the "Client ID" GUID and "Redirect URI",

          as you will use these in Step #3 below. You will also need your Azure Subscription ID and AAD tenant domain name, both of which you can copy from the "Settings" page in the management portal.



          Note:- If you want to use grant_type="Client_credential" and using client id and client_secret, Please ensure you have at least admin/co admin role in the subscription and you application have sufficient permission as mentioned above.






          share|improve this answer

























          • Thank you! I added "Windows Azure Service Management" to the application but unfortunately I get the same error.

            – Wuld
            Mar 11 at 13:23











          • Have you followed the blog i posted above in my answer?

            – Mohit Verma - MSFT
            Mar 11 at 13:26











          • Yeah, but it is not the problem to generate an AccessToken. That works fine.

            – Wuld
            Mar 11 at 13:43











          • Status code 403 is for forbidden only which means token generated from your service principal doesn't have the right level of permission. Might be possible that you are getting token as your app might have the access to windows azure directory, but that doesn't mean that you will be bale to call management api.

            – Mohit Verma - MSFT
            Mar 11 at 13:51













          0












          0








          0







          In your sample , Have you given sufficent permission to your service principal, which is permission to access Windows Azure Service Management APIs.



          Here is very good example , how to configure an app in Azure AD if you want to access management resources in Java



          https://blogs.msdn.microsoft.com/azureossds/2015/06/23/authenticating-azure-resource-management-rest-api-requests-using-java/



          Alternatively , Here is how you can configure the native app to use the Azure Rate card Api
          Step 1: Configure a Native Client application in your AAD tenant



          Before you can run the sample application, you will need to allow it to access your AAD tenant for authentication and authorization to access the Billing APIs. If you already have a Native Client Application configured that you would like to use (and it is configured according to the steps below), you can jump to Step 2.



          To configure a new AAD application:



          1. Sign in to the Azure portal, using credentials that have been granted service administrator/co-administrator access on the subscription which is trusting your AAD tenant, and granted Global Administrator access in the AAD tenant. See Manage Accounts, Subscriptions, and Administrative Roles for details on managing the service administrator and co-administrators.


          2. Select the AAD tenant you wish to use, and go to the "Applications" page.


          3. From there, you can use the "Add" feature to "Add a new application my organization is developing".


          4. Provide a name (ie: ConsoleApp-Billing-RateCard or similar) for the new application.


          5. Be sure to select the "Native Client Application" type, then specify a valid URL for "Redirect URI" (which can be http://localhost/ for the purposes of this sample), and click the check mark to save.


          6. After you've added the new application, select it again within the list of applications and click "Configure" so you can make sure the sample app will have permissions to access the Windows Azure Service Management APIs, which is the permission used to secure the Billing APIs.


          7. Scroll down to the to the "Permissions to other applications" section of your newly created application's configuration page. Then click the "Add Application" button, select the "Windows Azure Service Management" row, and click the check mark to save. After saving, hover the "Delegated Permissions" area on the right side of the "Windows Azure Service Management" row, click the "Delegated Permissions" drop down list, select the "Access Azure Service Management (preview)" option, and click "Save" again.


          NOTE: the "Windows Azure Active Directory" permission "Enable sign-on and read users' profiles" is enabled by default. It allows users to sign in to the application with their organizational accounts, enabling the application to read the profiles of signed-in users, such as their email address and contact information. This is a delegation permission, and gives the user the ability to consent before proceeding. Please refer to Adding, Updating, and Removing an Application for more depth on configuring an Azure AD tenant to enable an application to access your tenant.



          1. While you are on this page, also note/copy the "Client ID" GUID and "Redirect URI",

          as you will use these in Step #3 below. You will also need your Azure Subscription ID and AAD tenant domain name, both of which you can copy from the "Settings" page in the management portal.



          Note:- If you want to use grant_type="Client_credential" and using client id and client_secret, Please ensure you have at least admin/co admin role in the subscription and you application have sufficient permission as mentioned above.






          share|improve this answer















          In your sample , Have you given sufficent permission to your service principal, which is permission to access Windows Azure Service Management APIs.



          Here is very good example , how to configure an app in Azure AD if you want to access management resources in Java



          https://blogs.msdn.microsoft.com/azureossds/2015/06/23/authenticating-azure-resource-management-rest-api-requests-using-java/



          Alternatively , Here is how you can configure the native app to use the Azure Rate card Api
          Step 1: Configure a Native Client application in your AAD tenant



          Before you can run the sample application, you will need to allow it to access your AAD tenant for authentication and authorization to access the Billing APIs. If you already have a Native Client Application configured that you would like to use (and it is configured according to the steps below), you can jump to Step 2.



          To configure a new AAD application:



          1. Sign in to the Azure portal, using credentials that have been granted service administrator/co-administrator access on the subscription which is trusting your AAD tenant, and granted Global Administrator access in the AAD tenant. See Manage Accounts, Subscriptions, and Administrative Roles for details on managing the service administrator and co-administrators.


          2. Select the AAD tenant you wish to use, and go to the "Applications" page.


          3. From there, you can use the "Add" feature to "Add a new application my organization is developing".


          4. Provide a name (ie: ConsoleApp-Billing-RateCard or similar) for the new application.


          5. Be sure to select the "Native Client Application" type, then specify a valid URL for "Redirect URI" (which can be http://localhost/ for the purposes of this sample), and click the check mark to save.


          6. After you've added the new application, select it again within the list of applications and click "Configure" so you can make sure the sample app will have permissions to access the Windows Azure Service Management APIs, which is the permission used to secure the Billing APIs.


          7. Scroll down to the to the "Permissions to other applications" section of your newly created application's configuration page. Then click the "Add Application" button, select the "Windows Azure Service Management" row, and click the check mark to save. After saving, hover the "Delegated Permissions" area on the right side of the "Windows Azure Service Management" row, click the "Delegated Permissions" drop down list, select the "Access Azure Service Management (preview)" option, and click "Save" again.


          NOTE: the "Windows Azure Active Directory" permission "Enable sign-on and read users' profiles" is enabled by default. It allows users to sign in to the application with their organizational accounts, enabling the application to read the profiles of signed-in users, such as their email address and contact information. This is a delegation permission, and gives the user the ability to consent before proceeding. Please refer to Adding, Updating, and Removing an Application for more depth on configuring an Azure AD tenant to enable an application to access your tenant.



          1. While you are on this page, also note/copy the "Client ID" GUID and "Redirect URI",

          as you will use these in Step #3 below. You will also need your Azure Subscription ID and AAD tenant domain name, both of which you can copy from the "Settings" page in the management portal.



          Note:- If you want to use grant_type="Client_credential" and using client id and client_secret, Please ensure you have at least admin/co admin role in the subscription and you application have sufficient permission as mentioned above.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 11 at 10:09

























          answered Mar 11 at 9:50









          Mohit Verma - MSFTMohit Verma - MSFT

          1,1141617




          1,1141617












          • Thank you! I added "Windows Azure Service Management" to the application but unfortunately I get the same error.

            – Wuld
            Mar 11 at 13:23











          • Have you followed the blog i posted above in my answer?

            – Mohit Verma - MSFT
            Mar 11 at 13:26











          • Yeah, but it is not the problem to generate an AccessToken. That works fine.

            – Wuld
            Mar 11 at 13:43











          • Status code 403 is for forbidden only which means token generated from your service principal doesn't have the right level of permission. Might be possible that you are getting token as your app might have the access to windows azure directory, but that doesn't mean that you will be bale to call management api.

            – Mohit Verma - MSFT
            Mar 11 at 13:51

















          • Thank you! I added "Windows Azure Service Management" to the application but unfortunately I get the same error.

            – Wuld
            Mar 11 at 13:23











          • Have you followed the blog i posted above in my answer?

            – Mohit Verma - MSFT
            Mar 11 at 13:26











          • Yeah, but it is not the problem to generate an AccessToken. That works fine.

            – Wuld
            Mar 11 at 13:43











          • Status code 403 is for forbidden only which means token generated from your service principal doesn't have the right level of permission. Might be possible that you are getting token as your app might have the access to windows azure directory, but that doesn't mean that you will be bale to call management api.

            – Mohit Verma - MSFT
            Mar 11 at 13:51
















          Thank you! I added "Windows Azure Service Management" to the application but unfortunately I get the same error.

          – Wuld
          Mar 11 at 13:23





          Thank you! I added "Windows Azure Service Management" to the application but unfortunately I get the same error.

          – Wuld
          Mar 11 at 13:23













          Have you followed the blog i posted above in my answer?

          – Mohit Verma - MSFT
          Mar 11 at 13:26





          Have you followed the blog i posted above in my answer?

          – Mohit Verma - MSFT
          Mar 11 at 13:26













          Yeah, but it is not the problem to generate an AccessToken. That works fine.

          – Wuld
          Mar 11 at 13:43





          Yeah, but it is not the problem to generate an AccessToken. That works fine.

          – Wuld
          Mar 11 at 13:43













          Status code 403 is for forbidden only which means token generated from your service principal doesn't have the right level of permission. Might be possible that you are getting token as your app might have the access to windows azure directory, but that doesn't mean that you will be bale to call management api.

          – Mohit Verma - MSFT
          Mar 11 at 13:51





          Status code 403 is for forbidden only which means token generated from your service principal doesn't have the right level of permission. Might be possible that you are getting token as your app might have the access to windows azure directory, but that doesn't mean that you will be bale to call management api.

          – Mohit Verma - MSFT
          Mar 11 at 13:51



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55043117%2fazure-ratecard-authenticationfailed%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved