Azure-Samples / blockchain

Azure Blockchain Content and Samples
MIT License
823 stars 684 forks source link

Location of variables for REST API (url, resource, client_id, client_secret) #228

Closed kondulak10 closed 4 years ago

kondulak10 commented 4 years ago

We try to make simple REST calls, but we are getting unauthorized. Probably because we can not locate properly all the variables. We use Azure Blockchain Workbench. Can you guide us where to get them? Is there any additional configuration for REST API needed besides out of the box workbench?

{name} = Name of the Active directory (?) {resource_id} = AD -> App registrations -> Azure Blockchain Workbench, Application (client) ID (?) {client_id} = Likely wrong: newly created App registration with access (id) {client_secret} = Likely wrong: newly created App registration with access (secret)

const echoPostRequest = { 
  method: 'POST',
  url: 'https://login.microsoftonline.com/**{name}**/oauth2/token',
  headers: 
  { 
    'cache-control': 'no-cache',
    'Content-Type': 'application/x-www-form-urlencoded' 
  },
  body: 
  {
    mode: 'urlencoded',
    urlencoded: 
    [
        {key: "resource", value: "**{resource}**", disabled: false},
        {key: "client_id", value: "**{client_Id}**", disabled: false},
        {key: "client_secret", value: "**{client_secret}**", disabled :false},
        {key: "grant_type", value: "client_credentials", disabled: false}
    ]
  }
};