GCCHigh.Extensions.Identity contains modern OAuth2 extension methods for C# specifically targeted to the GCCHigh M365 environment. GCCHigh.Extensions supports all versions of.NET from 4.6.2 through 8.0.
The following classes have been exposed:
- Extensions.TenantConfig
- Extensions.Constants
- Extensions.Identity.App
- Extensions.Identity.Auth
- Extensions.Identity.AuthMan
- Extensions.Identity.Cert
- Extensions.Identity.Scopes
with these methods:
Multiple overloaded constructors allows for the construction and<br> population of the class instance properties. Each instance internally<br> manages its access token and renews it 5 minutes prior to expiration.<br> The class exposes the following useful objects:<br> GraphClient - Authenticated Microsoft.Graph.ServiceClient ready for use.<br> GraphBetaClient - Authenticated Microsoft.Graph.ServiceClient pointing<br> to the /beta endpoint and ready for use.<br> HttpClient - Authenticated Microsoft.Net.Http.HttpClient ready for use.<br> The HttpClient is useful when making direct REST calls.<br>
This class maintains and exposes the following two important objects:<br> ActiveAuth - The currently active Auth object.<br> AuthStack - A dictionary of all valid Auth objects.<br> The ActiveAuth object of type Auth which represents the currently active<br> Auth context in use. The AuthStack which is a dictionary containing<br> all valid Auth objects. When a request for a new Auth is made<br> through GetAuth(), the AuthStack is checked for a match. If the<br> matching Auth object is already in the AuthStack, it is simply reused<br> instead of expending the cycles and resources to generate a new one.<br> Because the Auth class maintains its access token internally, the Auth<br> object is always valid. The greatly improves performance especially in<br> cases where Auth switching between Graph and SharePoint happens regularly.<br>
Multiple overloads allows for the retrieval of a fully constructed Auth<br> object which is then stored in the managed AuthStack. Future requests<br> for the same Auth are then simply popped from the AuthStack for use.<br>
Multiple overloads allows the retrieval of either an authenticated<br> IConfidentialClientApplication or IPublicClientApplication.<br>
Returns a X509Certificate2 if available, given the thumbPrint string.<br> It will first attempt to load the cert from the CurrentUser context.<br> If that fails, it will attempt to load the cert from the<br> LocalMachine context. If this fails, it will return null.<br> For example:<br>
var cert = GetCertByThumbPrint(certificateThumbPrint)<br> will return the X509Certificate2 or null.<br> For more fine grained control, an overload exist that allows the<br> specification of a targeted StoreName and StoreLocation.<br>
Returns the string array representing the scopes for the given scopeType.
Returns the ScopeType given the string array of scopes.