This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import '../client/posts_client.dart'; | |
import '../client/models/post.dart'; | |
import 'package:microsoft_kiota_bundle/microsoft_kiota_bundle.dart'; | |
import 'package:microsoft_kiota_abstractions/microsoft_kiota_abstractions.dart'; | |
void main(List<String> arguments) async { | |
var authenticationProvider = AnonymousAuthenticationProvider(); | |
var requestAdapter = | |
DefaultRequestAdapter(authProvider: authenticationProvider); | |
var client = PostsClient(requestAdapter); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repositories { | |
// Use Maven Central for resolving dependencies. | |
mavenCentral() | |
// Add sonatype repository | |
maven { | |
url 'https://oss.sonatype.org/content/repositories/snapshots/' | |
} | |
} | |
dependencies { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User user = new User(); | |
user.setDisplayName("displayName"); | |
user.setMail("email@contoso.onmicrosoft.com"); | |
graphClient | |
.users() | |
.post(user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
User user = new User(); | |
user.displayName = "displayName"; | |
user.userPrincipalName = "email@contoso.onmicrosoft.com"; | |
graphClient | |
.users() | |
.buildRequest() | |
.post(user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int memberCount = graphClient | |
.groups() | |
.byGroupId("Id") | |
.members() | |
.graphUser() | |
.count() //Where applicable to enable the use of $count | |
.get(requestConfiguration -> { | |
requestConfiguration.headers.add("ConsistencyLevel", "Eventual"); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UserCollectionResponse response = graphClient | |
.groups() | |
.byGroupId("Id") | |
.members() | |
.graphUser() | |
.get( requestConfiguration -> { | |
requestConfiguration.headers.add("ConsistencyLevel", "Eventual"); | |
requestConfiguration.queryParameters.top = 10; | |
}); |
NewerOlder