// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new CustomClaimsPolicy
{
OdataType = "#microsoft.graph.customClaimsPolicy",
IncludeBasicClaimSet = boolean,
IncludeApplicationIdInIssuer = boolean,
AudienceOverride = "String",
Claims = new List<CustomClaimBase>
{
new CustomClaim
{
OdataType = "microsoft.graph.customClaim",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.ServicePrincipals["{servicePrincipal-id}"].ClaimsPolicy.PutAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewCustomClaimsPolicy()
includeBasicClaimSet := boolean
requestBody.SetIncludeBasicClaimSet(&includeBasicClaimSet)
includeApplicationIdInIssuer := boolean
requestBody.SetIncludeApplicationIdInIssuer(&includeApplicationIdInIssuer)
audienceOverride := "String"
requestBody.SetAudienceOverride(&audienceOverride)
customClaimBase := graphmodels.NewCustomClaim()
claims := []graphmodels.CustomClaimBaseable {
customClaimBase,
}
requestBody.SetClaims(claims)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
claimsPolicy, err := graphClient.ServicePrincipals().ByServicePrincipalId("servicePrincipal-id").ClaimsPolicy().Put(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
CustomClaimsPolicy customClaimsPolicy = new CustomClaimsPolicy();
customClaimsPolicy.setOdataType("#microsoft.graph.customClaimsPolicy");
customClaimsPolicy.setIncludeBasicClaimSet(boolean);
customClaimsPolicy.setIncludeApplicationIdInIssuer(boolean);
customClaimsPolicy.setAudienceOverride("String");
LinkedList<CustomClaimBase> claims = new LinkedList<CustomClaimBase>();
CustomClaim customClaimBase = new CustomClaim();
customClaimBase.setOdataType("microsoft.graph.customClaim");
claims.add(customClaimBase);
customClaimsPolicy.setClaims(claims);
CustomClaimsPolicy result = graphClient.servicePrincipals().byServicePrincipalId("{servicePrincipal-id}").claimsPolicy().put(customClaimsPolicy);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\CustomClaimsPolicy;
use Microsoft\Graph\Beta\Generated\Models\CustomClaimBase;
use Microsoft\Graph\Beta\Generated\Models\CustomClaim;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new CustomClaimsPolicy();
$requestBody->setOdataType('#microsoft.graph.customClaimsPolicy');
$requestBody->setIncludeBasicClaimSet(boolean);
$requestBody->setIncludeApplicationIdInIssuer(boolean);
$requestBody->setAudienceOverride('String');
$claimsCustomClaimBase1 = new CustomClaim();
$claimsCustomClaimBase1->setOdataType('microsoft.graph.customClaim');
$claimsArray []= $claimsCustomClaimBase1;
$requestBody->setClaims($claimsArray);
$result = $graphServiceClient->servicePrincipals()->byServicePrincipalId('servicePrincipal-id')->claimsPolicy()->put($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.custom_claims_policy import CustomClaimsPolicy
from msgraph_beta.generated.models.custom_claim_base import CustomClaimBase
from msgraph_beta.generated.models.custom_claim import CustomClaim
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = CustomClaimsPolicy(
odata_type = "#microsoft.graph.customClaimsPolicy",
include_basic_claim_set = Boolean,
include_application_id_in_issuer = Boolean,
audience_override = "String",
claims = [
CustomClaim(
odata_type = "microsoft.graph.customClaim",
),
],
)
result = await graph_client.service_principals.by_service_principal_id('servicePrincipal-id').claims_policy.put(request_body)