title: graph beta /groups/$id/channels Authorization has been denied for this request
body: <p>i want to get all channels from an azure group.
  Querying the groups works and return all azure groups. however, query the group channels result in an error</p>
  
  <pre><code>Authorization has been denied for this request
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>$appID = "f9....22"
  $appSecret="FH..8="
  $tokenAuthURI = "https://login.microsoftonline.com/c6...59/oauth2/token"
  $requestBody = "grant_type=client_credentials" + 
              "&amp;client_id=$appID" +
              "&amp;resource=https://graph.microsoft.com" +
              "&amp;client_secret=$appSecret"
  $tokenResponse = Invoke-RestMethod -Method Post -Uri $tokenAuthURI -body $requestBody -ContentType "application/x-www-form-urlencoded"
  $accessToken = $tokenResponse.access_token
  $groupsListURI = "https://graph.microsoft.com/beta/groups?`$filter=groupTypes/any(c:c+eq+`'Unified`')"
  $graphResponse = Invoke-RestMethod -Method Get -Uri $groupsListURI -Headers @{"Authorization"="Bearer $accessToken"}
  $TeamsList = @()
  foreach ($group in $graphResponse.value)
          {
              if($group.groupTypes -eq "Unified") {
                  $id= $group.id
                  Try
                  {
                      $url = "https://graph.microsoft.com/beta/groups/$id/channels"
                      $team = Invoke-RestMethod -Method Get -Uri $url -Headers @{"Authorization"="Bearer $accessToken"}
                      "Channel count for " + $group.displayName + " is " + $team.value.id.count
                  }
                  Catch
                  {
                      $result = $_.Exception.Response.GetResponseStream()
                      $reader = New-Object System.IO.StreamReader($result)
                      $reader.BaseStream.Position = 0
                      $reader.DiscardBufferedData()
                      $reader.ReadToEnd()
                      $team = $null
                  }
  }
  }
  </code></pre>
  
  <p>the catch result is ""</p>
  
  <pre><code>{
    "error": {
      "code": "",
      "message": "Authorization has been denied for this request.",
      "innerError": {
        "request-id": "7c...89",
        "date": "2017-12-14T14:19:39"
      }
    }
  }
  </code></pre>
  
  <p>thx</p>
  
  <p><strong><em>UPDATE</em></strong></p>
  
  <p>also tried adding either $scope or $scope2. same result</p>
  
  <pre><code>$scope = "https://graph.microsoft.com/Group.ReadWrite.All https://graph.microsoft.com/Group.Read.All https://graph.microsoft.com/User.ReadBasic.All https://graph.microsoft.com/Directory.AccessAsUser.All https://graph.microsoft.com/Directory.Read.All"
  $scope2 = "Group.ReadWrite.All Group.Read.All Directory.Read.All Directory.AccessAsUser.All User.ReadBasic.All"
  
  
  $requestBody = "grant_type=client_credentials" + 
              "&amp;client_id=$appID" +
              "&amp;resource=https://graph.microsoft.com" +
              "&amp;client_secret=$appSecret" +
              "&amp;scope=$scope2"
  </code></pre>