Search code examples
azuremicrosoft-graph-api

Get a list of customer tenants without Partner Center API access


I need to find out how to get a list of our Partner Center customer tenants without access to the Partner Center API as we do not meet the criteria to access it.

We have GDAP relationships with every tenant, as well as an App Registration that has consent with every tenant. Is there a way in the Graph API to access a list of tenants associated with our account? I really only need the Tenant IDs and nothing else.


Solution

  • Note that: It is not possible to get a list of our Partner Center customer tenants without access to the Partner Center API as we do not meet the criteria to access it.

    Hence, you must be having access to the Partner Center API. In case if you get access check the below:

    Connect to Partner Center, use the below script:

    $appId = "ClientID"
    $appSecret = ConvertTo-SecureString -String "Secret" -AsPlainText -Force
    $tenantId = "TenantID" 
    $credential = [PSCredential]::new($appId, $appSecret)
    
    $tokenSplat = @{
        ApplicationId        = $appId
        Credential           = $credential
        Scopes               = "https://api.partnercenter.microsoft.com/user_impersonation"
        ServicePrincipal     = $true
        TenantId             = $tenantId
        UseAuthorizationCode = $true
    }
    
    $token = New-PartnerAccessToken @tokenSplat
    
    $token.RefreshToken
    

    enter image description here

    Now connect to Partner Center:

    $connectSplat = @{
        ApplicationId = $appId
        Credential    = $credential
        RefreshToken  = $token.RefreshToken
    }
    
    Connect-PartnerCenter @connectSplat
    

    As confirmed by you as you have the access there is no way to get access to Partner Center API.

    Is there maybe a way to view the tenants that are consented with the app? Shouldn't the Graph API have a way to see that?

    To fetch the tenants the multitenant application has consented, you need to be the user of that particular tenant.

    • Hence, there is no way to view the tenants that are consented with the app via Microsoft Graph API or any other API.

    Reference:

    Azure AD Multi-tenant App - Find what tenant provided admin consent - Stack Overflow by RamaraoAdapa