title: Getting error "Need Admin Approval" while calling PowerBI REST API
body: <p>I want to extract dataset refresh history for the dataset. I am using the REST API in PowerShell script. I registered native app and provided all the permissions but getting error "Need admin approval".
  What admin approval needed?</p>
  
  <p>While running the above code getting the error</p>
  
  <blockquote>
    <p>Need admin approval</p>
    
    <p>needs permission to access resources in your organization that only an
    admin can grant. Please ask an admin to grant permission to this app
    before you can use it.</p>
    
    <p>Have an admin account? Sign in with that account Return to the
    application without granting consent" Note: I am not the admin of my
    cloud</p>
  </blockquote>
  
  <p>Please help me what needs to be done to resolve this error. Also what approval is required and how can my admin provide the access?</p>
  
  <pre class="lang-bsh prettyprint-override"><code>$clientId = "NativeAppClientId"
  
  # Calls the Active Directory Authentication Library (ADAL) to authenticate against AAD
  function GetAuthToken {
      if (-not (Get-Module AzureRm.Profile)) {
          Import-Module AzureRm.Profile
      }
  
      $redirectUri = "urn:ietf:wg:oauth:2.0:oob" 
      $resourceAppIdURI = "https://analysis.windows.net/powerbi/api"
      $authority = "https://login.microsoftonline.com/common/oauth2/authorize";
      $authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority
      $authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")
      return $authResult
  }
  
  # Get the auth token from AAD
  $token = GetAuthToken
  # Building Rest API header with authorization token
  $authHeader = @{
      'Content-Type'  = 'application/json'
      'Authorization' = $token.CreateAuthorizationHeader()
  }
  # properly format groups path
  $groupsPath = ""
  if ($groupID -eq "me") {
      $groupsPath = "myorg"
  } else {
      $groupsPath = "myorg/groups/$groupID"
  }
  
  # Check the refresh history
  $uri = "https://api.powerbi.com/v1.0/$groupsPath/datasets/$datasetID/refreshes"
  Invoke-RestMethod -Uri $uri -Headers $authHeader -Method GET -Verbose
  </code></pre>