Skip to content

Instantly share code, notes, and snippets.

View maisarissi's full-sized avatar

Maísa Rissi maisarissi

  • São Paulo, Brazil
  • 15:54 (UTC -03:00)
View GitHub Profile
@maisarissi
maisarissi / build.gradle
Last active February 7, 2024 19:42
microsoftgraph-java-v6-sefl-serve-kiota-build-gradle
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
// Add sonatype repository
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
@maisarissi
maisarissi / SelfServeKiota.java
Created December 13, 2023 17:33
microsoftgraph-java-v6-sefl-serve-kiota
final String[] scopes = new String[] {"Mail.Read", "Mail.Send", "User.Read"};
final String[] allowedHosts = new String[] {"graph.microsoft.com"};
DeviceCodeCredential deviceCodeCredential = new DeviceCodeCredentialBuilder()
.clientId(appId)
.tenantId(tenantId)
.challengeConsumer(challenge -> {
System.out.println(challenge.getMessage());
})
.build();
@maisarissi
maisarissi / CreateBothClients.java
Created December 12, 2023 14:51
microsoftgraph-java-v6-v1-beta-clients
DeviceCodeCredential deviceCodeCredential = new DeviceCodeCredentialBuilder()
.clientId(clientId)
.tenantId(tenantId)
.challengeConsumer(challenge -> System.out.println(challenge.getMessage()))
.build();
//create a client for calling v1.0 endpoint
com.microsoft.graph.serviceclient.GraphServiceClient graphClient =
new com.microsoft.graph.serviceclient.GraphServiceClient(
deviceCodeCredential,
@maisarissi
maisarissi / BatchCollection.java
Last active December 12, 2023 15:14
microsoftgraph-java-v6-batch-collection
//Use adjusted pageIterator sample from above to get list of first 100 messageIds.
MessageCollectionResponse messages = graphClient
.me()
.messages()
.get();
List<String> messagesIdList = new LinkedList<String>();
PageIterator pageIterator = new PageIterator.Builder<Message, MessageCollectionResponse>()
.client(graphClient)
.collectionPage(messages)
@maisarissi
maisarissi / BackingStore.java
Created December 7, 2023 22:23
microsoftgraph-java-v6-backing-store
// get the object
Event event = graphClient
.me()
.events()
.byEventId("event-id")
.get();
// the backing store will keep track that the property change and send the updated value.
event.setRecurrence(null); // set to null
@maisarissi
maisarissi / NewRequest.java
Created December 7, 2023 21:00
microsoftgraph-java-v6-new-create-user
User user = new User();
user.setDisplayName("displayName");
user.setMail("email@contoso.onmicrosoft.com");
graphClient
.users()
.post(user);
@maisarissi
maisarissi / OldRequest.java
Last active December 7, 2023 21:00
microsoftgraph-java-v5-old-create-user
User user = new User();
user.displayName = "displayName";
user.userPrincipalName = "email@contoso.onmicrosoft.com";
graphClient
.users()
.buildRequest()
.post(user);
@maisarissi
maisarissi / Count.java
Last active December 7, 2023 19:48
microsoftgraph-java-v6-count
int memberCount = graphClient
.groups()
.byGroupId("Id")
.members()
.graphUser()
.count() //Where applicable to enable the use of $count
.get(requestConfiguration -> {
requestConfiguration.headers.add("ConsistencyLevel", "Eventual");
});
@maisarissi
maisarissi / RequestConfiguration.java
Last active December 7, 2023 18:50
microsoftgraph-java-v6-request-configuration
UserCollectionResponse response = graphClient
.groups()
.byGroupId("Id")
.members()
.graphUser()
.get( requestConfiguration -> {
requestConfiguration.headers.add("ConsistencyLevel", "Eventual");
requestConfiguration.queryParameters.top = 10;
});
@maisarissi
maisarissi / ODataCast.java
Last active January 16, 2024 19:35
microsoftgraph-java-v6-odata-cast
//Fetching the members of a group who are of the type User
//graph.microsoft.com/v1.0/groups/{group-id}/members/microsoft.graph.user
UserCollectionResponse usersInGroup = graphClient
.groups()
.byGroupId("group-id")
.members()
.graphUser()
.get();
List<User> users = usersInGroup.getValue();