Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string authority = "https://login.microsoftonline.com/{0}";
- string graphResourceId = "https://graph.microsoft.com";
- string tenantId = "tenant id";
- string clientId = "client Id";
- string secret = "sercet key";
- authority = String.Format(authority, tenantId);
- AuthenticationContext authContext = new AuthenticationContext(authority);
- var accessToken = authContext.AcquireTokenAsync(graphResourceId, new ClientCredential(clientId, secret)).Result.AccessToken;
- var graphserviceClient = new GraphServiceClient(
- new DelegateAuthenticationProvider(
- requestMessage =>
- {
- requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
- return Task.FromResult(0);
- }));
- var dic = new Dictionary<string, object> {{"@odata.type", "microsoft.graph.invitedUserMessageInfo"}};
- Invitation invitation = new Invitation
- {
- InvitedUserEmailAddress = "email address",
- InvitedUserMessageInfo = new InvitedUserMessageInfo{AdditionalData = dic },
- InvitedUserDisplayName = "xxx",
- SendInvitationMessage = false,
- InviteRedirectUrl = "xxxxx"
- };
- var result = graphserviceClient.Invitations.Request().AddAsync(invitation).Result;
Add Comment
Please, Sign In to add comment