BatchScoring/ServicePrincipalAuthentication.cs
/// <summary>
/// This code was taken from an MSDN blog post directly (with minor changes to include
/// the class instances of Tenant, ClientId, and ClientKey
/// </summary>
/// <returns></returns>
This code was taken from an MSDN blog post directly (with minor changes to include
the class instances of Tenant, ClientId, and ClientKey
This code was taken from an MSDN blog post directly ( with minor changes to include the class instances of Tenant ClientId and ClientKey
public async Task<String> GetToken()
        {
            string authContextURL = "https://login.windows.net/" + this.Tenant;
            var authenticationContext = new AuthenticationContext(authContextURL);
            var credential = new ClientCredential(this.ClientId, this.ClientKey);
            var result = await authenticationContext
                .AcquireTokenAsync("https://management.azure.com/", credential);
            if (result == null)
            {
                throw new InvalidOperationException("Failed to obtain the JWT token");
            }
            string token = result.AccessToken;
            return token;
        }
public async Task < String > GetToken ( ) { string authContextURL = " " + this . Tenant ; var authenticationContext = new AuthenticationContext ( authContextURL ) ; var credential = new ClientCredential ( this . ClientId , this . ClientKey ) ; var result = await authenticationContext . AcquireTokenAsync ( " " , credential ) ; if ( result == null ) { throw new InvalidOperationException ( " " ) ; } string token = result . AccessToken ; return token ; }
This code was taken from an MSDN blog post directly (with minor changes to include
the class instances of Tenant, ClientId, and ClientKey
This code was taken from an MSDN blog post directly ( with minor changes to include the class instances of Tenant ClientId and ClientKey
None