// Create the InteractiveBrowserCredential using details
// from app registered in the Azure AD for US Government portal
var credential = new InteractiveBrowserCredential(
"YOUR_TENANT_ID",
"YOUR_CLIENT_ID",
new InteractiveBrowserCredentialOptions
{
// https://login.microsoftonline.us
AuthorityHost = AzureAuthorityHosts.AzureGovernment,
RedirectUri = new Uri("YOUR_REDIRECT_URI"),
});
// Create the authentication provider
var authProvider = new AzureIdentityAuthenticationProvider(
credential,
isCaeEnabled: true,
scopes: ["https://graph.microsoft.us/.default"]);
// Create the Microsoft Graph client object using
// the Microsoft Graph for US Government L4 endpoint
// NOTE: The API version must be included in the URL
var graphClient = new GraphServiceClient(
authProvider,
"https://graph.microsoft.us/v1.0");
// Create the InteractiveBrowserCredential using details
// from app registered in the Azure AD for US Government portal
credential, _ := azidentity.NewInteractiveBrowserCredential(
&azidentity.InteractiveBrowserCredentialOptions{
ClientID: "YOUR_CLIENT_ID",
TenantID: "YOUR_TENANT_ID",
ClientOptions: policy.ClientOptions{
// https://login.microsoftonline.us
Cloud: cloud.AzureGovernment,
},
RedirectURL: "YOUR_REDIRECT_URL",
})
// Create the authentication provider
authProvider, _ := auth.NewAzureIdentityAuthenticationProviderWithScopes(credential,
[]string{"https://graph.microsoft.us/.default"})
// Create a request adapter using the auth provider
adapter, _ := graph.NewGraphRequestAdapter(authProvider)
// Set the service root to the
// Microsoft Graph for US Government L4 endpoint
// NOTE: The API version must be included in the URL
adapter.SetBaseUrl("https://graph.microsoft.us/v1.0")
// Create a Graph client using request adapter
graphClient := graph.NewGraphServiceClient(adapter)
// Create the InteractiveBrowserCredential using details
// from app registered in the Azure AD for US Government portal
final InteractiveBrowserCredential credential = new InteractiveBrowserCredentialBuilder()
.clientId("YOUR_CLIENT_ID").tenantId("YOUR_TENANT_ID")
// https://login.microsoftonline.us
.authorityHost(AzureAuthorityHosts.AZURE_GOVERNMENT)
.redirectUrl("YOUR_REDIRECT_URI").build();
final String[] scopes = new String[] {"https://graph.microsoft.us/.default"};
// Create the authentication provider
if (null == scopes || null == credential) {
throw new Exception("Unexpected error");
}
final GraphServiceClient graphClient = new GraphServiceClient(credential, scopes);
// Set the service root to the
// Microsoft Graph for US Government L4 endpoint
// NOTE: The API version must be included in the URL
graphClient.getRequestAdapter().setBaseUrl("https://graph.microsoft.us/v1.0");
$scopes = ['https://graph.microsoft.us/.default'];
// Create the Microsoft Graph client object using
// the Microsoft Graph for US Government L4 endpoint
// $tokenRequestContext is one of the token context classes
// from Microsoft\Kiota\Authentication\Oauth
$graphClient = new GraphServiceClient($tokenRequestContext, $scopes, NationalCloud::US_GOV);
scopes = ['https://graph.microsoft.us/.default']
credential = InteractiveBrowserCredential(
tenant_id='YOUR_TENANT_ID',
client_id='YOUR_CLIENT_ID',
redirect_uri='YOUR_REDIRECT_URI')
auth_provider = AzureIdentityAuthenticationProvider(credential, scopes=scopes)
# Create the HTTP client using
# the Microsoft Graph for US Government L4 endpoint
http_client = GraphClientFactory.create_with_default_middleware(
host=NationalClouds.US_GOV)
adapter = GraphRequestAdapter(auth_provider, http_client)
graph_client = GraphServiceClient(request_adapter=adapter)
// Create the InteractiveBrowserCredential using details
// from app registered in the Azure AD for US Government portal
const credential = new InteractiveBrowserCredential({
clientId: 'YOUR_CLIENT_ID',
tenantId: 'YOUR_TENANT_ID',
// https://login.microsoftonline.us
authorityHost: AzureAuthorityHosts.AzureGovernment,
redirectUri: 'YOUR_REDIRECT_URI',
});
// Create the authentication provider
const authProvider = new TokenCredentialAuthenticationProvider(credential, {
scopes: ['https://graph.microsoft.us/.default'],
});
// Create the Microsoft Graph client object using
// the Microsoft Graph for US Government L4 endpoint
// NOTE: Do not include the version in the baseUrl
const graphClient = Client.initWithMiddleware({
authProvider: authProvider,
baseUrl: 'https://graph.microsoft.us',
});