Guest User

Untitled

a guest
Jan 24th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. string authority = "https://login.microsoftonline.com/{0}";
  2. string graphResourceId = "https://graph.microsoft.com";
  3. string tenantId = "tenant id";
  4. string clientId = "client Id";
  5. string secret = "sercet key";
  6. authority = String.Format(authority, tenantId);
  7. AuthenticationContext authContext = new AuthenticationContext(authority);
  8. var accessToken = authContext.AcquireTokenAsync(graphResourceId, new ClientCredential(clientId, secret)).Result.AccessToken;
  9. var graphserviceClient = new GraphServiceClient(
  10. new DelegateAuthenticationProvider(
  11. requestMessage =>
  12. {
  13. requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
  14.  
  15. return Task.FromResult(0);
  16. }));
  17. var dic = new Dictionary<string, object> {{"@odata.type", "microsoft.graph.invitedUserMessageInfo"}};
  18.  
  19. Invitation invitation = new Invitation
  20. {
  21. InvitedUserEmailAddress = "email address",
  22. InvitedUserMessageInfo = new InvitedUserMessageInfo{AdditionalData = dic },
  23. InvitedUserDisplayName = "xxx",
  24. SendInvitationMessage = false,
  25. InviteRedirectUrl = "xxxxx"
  26.  
  27. };
  28. var result = graphserviceClient.Invitations.Request().AddAsync(invitation).Result;
Add Comment
Please, Sign In to add comment