question

obsajenns avatar image
0 Votes"
obsajenns asked Jerryzy edited

PartnerCenter.Exception 'Unauthorized access' using app authentication

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?


partner-center-api
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

Jerryzy avatar image
0 Votes"
Jerryzy answered Jerryzy edited

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



untitled.png (27.3 KiB)
image-5.png (55.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.