powershell - Service to Service Calls Using Client Credentials -


i tried create alias group in office 365 using below code shows error.how solve this. tried use service service calls method. got token generated. how check valid or not? possible create alias using api group without powershell option? if no kindly advice me other options..

string clientid = "************"; string clientsecret = "******"; string tenantid = "********"; //string resourceuri = "http://office.microsoft.com/outlook/"; string redirecturi = "https://login.live.com/oauth20_desktop.srf"; var authuri = "https://login.windows.net/" + tenantid + "/oauth2/authorize/"; var resource_url = "https://graph.windows.net";  httpclient client = new httpclient(); var authcontext = new authenticationcontext(authuri); var credential = new clientcredential(clientid: clientid, clientsecret: clientsecret); var result = authcontext.acquiretokenasync(resource_url, credential).result; client.defaultrequestheaders.add("authorization", "bearer " + result.accesstoken); string content = @"{               'displayname': 'mailgrouptest',               'grouptypes': ['unified'],               'mailenabled': true,               'mailnickname': 'mailalias1',               'securityenabled': false       }";   var httpcontent = new stringcontent(content, encoding.getencoding("utf-8"), "application/json");  var response = client.postasync("https://graph.microsoft.com/v1.0/groups", httpcontent).result;  console.writeline(response.content.readasstringasync().result); 

when run code in console shows error this....is problem token ? or tenant id?

{   "error": { "code": "invalidauthenticationtoken", "message": "access token validation failure.", "innererror": {``   "request-id": "*****-***-",   "date": "2016-05-25t04:53:08"     }   } } 

kindly advice me create alias group in api

the mailnickname of group not able update using microsoft graph @ present.

as workaround, can create new group specific mailnickname wanted , use new group. here code create group mailnicekname reference:

        string clientid = "";         string clientsecret = "";         string tenant = "yourdomain.onmicrosoft.com";          var authuri = "https://login.microsoftonline.com/"+tenant+"/oauth2/token";         var resource_url = "https://graph.microsoft.com";          httpclient client = new httpclient();         var authcontext = new authenticationcontext(authuri);         var credential = new clientcredential(clientid: clientid, clientsecret: clientsecret);         var result = authcontext.acquiretokenasync(resource_url, credential).result;         client.defaultrequestheaders.add("authorization", "bearer " + result.accesstoken);          string content = @"{  'description': 'description-value',   'displayname': 'displayname-value',   'grouptypes': [     'unified'   ],   'mailenabled': true,   'mailnickname': 'mailnickname-value',   'securityenabled': false }";         var httpcontent = new stringcontent(content, encoding.getencoding("utf-8"), "application/json");         //var response = client.getasync("https://graph.microsoft.com/v1.0/groups").result;         var response = client.postasync("https://graph.microsoft.com/v1.0/groups",httpcontent).result;         console.writeline(response.content.readasstringasync().result); 

more detail goupr rest api, please refer here.

for error “invalidauthenticationtoken” request access token incorrect resource. use microsoft graph api, need specify resource “https://graph.microsoft.com” instead of “https://graph.windows.net”.

in addition, if want mailnickname of group updateable, can try submit feedback here.


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -