Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

How to get AssemblyAuthenticationContext from getService() in plugin?

(0) ShareShare
ReportReport
Posted on by

I've seen IAssemblyAuthenticationContext used in plugins. I want to instantiate it in particular so I can use its AcquireToken() method. However, whenever I look in serviceProvider that is passed into the Execute() function for it, it is never available. This makes my AssemblyAuthContext variable below always null.

public void Execute(IServiceProvider serviceProvider)
{
    var PluginExecutionContext = serviceProvider.Get();
    var TracingService = new LocalTracingService(serviceProvider);
    
    // This is always null
    var AssemblyAuthContext = serviceProvider.Get();
    
    // What I wwant to do
    string token = AssemblyAuthContext.AcquireToken("url", "authResource, AuthenticationType.ClientAssertionCertificateWithX5c);
}

Anyone know how to make this available in a plugin? Do you have to pass it in somehow?

  • vdblohowiak Profile Picture
    on at
    RE: How to get AssemblyAuthenticationContext from getService() in plugin?

    It's the same method as doing serviceProvider.Get<IAssemblyAuthenticationContext>();

    I can debug the plugin and inspect what's in serviceProvider. Nothing of type "IAssemblyAuthenticationContext" is in there.

  • Eric benco Profile Picture
    320 on at
    RE: How to get AssemblyAuthenticationContext from getService() in plugin?

    what if happens if you try

    serviceProvider.GetService(typeof(IAssemblyAuthenticationContext));

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,099 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans