PartnerCenter.Exception 'Unauthorized access' using app authentication

ajenns 21 Reputation points
2020-05-15T11:38:42.563+00:00

So I am using the Peek CSP Billing example to do custom billing for our CSP clients. I had this working using app+user authentication, but since, I have had to update the dll's which caused the solution to no longer work. As we are not yet ready to do secure model, I wanted to switch to app authentication. It is failing on partnerOperations.Customers.Get() call.

Here are my excerpts:
AuthenticationHelper.cs

        public  IAggregatePartner GetCAPartnerCenterTokenUsingAppCredentials()  
        {  
            IPartnerCredentials partnerCredentials =  
                PartnerCredentials.Instance.GenerateByApplicationCredentials(  
                    this.Configuration.ApplicationAuthentication.CAApplicationId,  
                    this.Configuration.ApplicationAuthentication.CAApplicationSecret,  
                    this.Configuration.ApplicationAuthentication.CAApplicationDomain);  
  
            // Create operations instance with partnerCredentials.  
            return PartnerService.Instance.CreatePartnerOperations(partnerCredentials);  
        }  

Then in my CspUsageController.cs I have:

            var partnerOperations = this.authHelper.GetCAPartnerCenterTokenUsingAppCredentials();  
  
            SeekBasedResourceCollection<Customer> customersPage = partnerOperations.Customers.Get();  

I have registered my Native App in the Partner Center. This also is shown in the AAD app registrations which I have given the app API permissions to Access the Partner Center.

8239-screen-shot-2020-05-15-at-63541-am.png

I have confirmed that Customers.Get() is supported by app authentication. Why am I still getting 'Unauthorized access' ?

I know this is not a user, but where can I assign App Registration permission to the Partner Center API?

Microsoft Partner Center API
Microsoft Partner Center API
Microsoft Partner Center: A Microsoft website for partners that provides access to product support, a partner community, and other partner services.API: A software intermediary that allows two applications to interact with each other.
313 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jerryzy 10,566 Reputation points
    2020-05-18T07:24:38.69+00:00

    Hi obsajenns,

    Please use the Web App's Client Id and Secret instead of Native App in Partner Center:

    8432-untitled.png

    Then it's available to execute Customers.Get():

    8461-image-5.png

    0 comments No comments

0 additional answers

Sort by: Most helpful