1

I am trying to use Graph APIs to get list of "Azure B2C AD TrustFrameworkPolicy" in Java

These are my dependencies in the POM

        <dependency>
            <groupId>com.microsoft.graph</groupId>
            <artifactId>microsoft-graph</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.graph</groupId>
            <artifactId>microsoft-graph-core</artifactId>
            <version>1.0.5</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.graph</groupId>
            <artifactId>microsoft-graph-auth</artifactId>
            <version>0.2.0</version>
        </dependency>

I have clientId, secret and b2ctenant

I am creating an authentication provider :

 ClientCredentialProvider authProvider = 
            new ClientCredentialProvider(clientId,
                    scopes,
                    clientSecret,
                    b2cTenantId,
                    endpoint);

And using the auth provider in the graph service client,

    IGraphServiceClient graphClient = GraphServiceClient.builder()
                              .authenticationProvider(authProvider)
                              .buildClient(); 

But when I am using the "ITrustFrameworkPolicyCollectionPage" I am getting error -> Can not be resolved to a type

    ITrustFrameworkPolicyCollectionPage policies = graphClient.trustFramework().policies()
            .buildRequest()
            .get();

I am trying to find which maven dependency I missed, or I dont understand why it won't work. Some body please help.

URL https://learn.microsoft.com/fr-fr/graph/api/trustframework-list-trustframeworkpolicies?view=graph-rest-beta&tabs=java

SharadxDutta
  • 1,058
  • 8
  • 21

1 Answers1

1

It is broken at the moment...

Instead use this...

         ClientCredentialProvider authProvider = 
                 new ClientCredentialProvider(clientId,
                         scopes,
                         clientSecret,
                         b2cTenantId,
                         endpoint); 
        
         OkHttpClient client = HttpClients.createDefault(authProvider);
         Request request = new Request.Builder().url("https://graph.microsoft.com/beta/trustFramework/policies/B2C_1A_User_MigrationClients/$value").build();
         Response response = client.newCall(request).execute();
         System.out.println(response.body().string());

This will give you the XML you need which is nothing but the policy.

horizon
  • 453
  • 2
  • 12