Skip to main content



No record found.

Microsoft Dynamics CRM forum

How to get AssemblyAuthenticationContext from getService() in plugin?

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
    vdblohowiak 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
    Eric benco 320 on at
    RE: How to get AssemblyAuthenticationContext from getService() in plugin?

    what if happens if you try


Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans