office365 - No mailbox was found that includes the external directory object ID that was specified when using direct authorization -


when access graph api using graph explorer logged on work account following rest call works without problems

https://graph.microsoft.com/v1.0/groups('42bc2ab5-230f-475c-8663-7c319d0b6696')/conversations?expand=threads(expand=posts) 

the guid id of office 365 group

when try accessing using direct authorisation of used following guide configure windows console app

https://azure.microsoft.com/en-gb/documentation/articles/active-directory-v2-protocols-oauth-client-creds/

the following 404 error returned following json response.

{   "error": {     "code": "errornonexistentmailbox",     "message": "no mailbox found includes external directory object id specified.",     "innererror": {       "request-id": "e8a5f034-3e8c-496c-896e-250acea6fe1c",       "date": "2016-10-26t10:16:27"     }   } } 

if access group directly using following rest call works ok

https://graph.microsoft.com/v1.0/groups('42bc2ab5-230f-475c-8663-7c319d0b6696') 

but when try access conversations error above returned.

my app configured following permissions using https://apps.dev.microsoft.com

delegated permissions

mail.read, mail.read.shared, user.read, group.read.all (admin only), group.readwrite.all (admin only)

application permissions

group.read.all (admin only), group.readwrite.all (admin only), mail.read (admin only), user.read.all (admin only)

this code i'm using in console app

class program     {         private const string authority_format = "https://login.microsoftonline.com/{0}/v2.0";         private const string graph_scope = "https://graph.microsoft.com/.default";         private const string group_attachments_graph_query = "https://graph.microsoft.com/v1.0/groups('42bc2ab5-230f-475c-8663-7c319d0b6696')/conversations?expand=threads(expand=posts)";         static void main(string[] args)         {             scangroupconversations().wait();              console.writeline("press key continue...");             console.read();         }          static async task scangroupconversations()         {             // token microsoft graph             confidentialclientapplication daemonclient =                 new confidentialclientapplication(                     string.format(authority_format, configurationmanager.appsettings["tennantid"]),                     configurationmanager.appsettings["clientid"], configurationmanager.appsettings["redirecturi"],                     new clientcredential(configurationmanager.appsettings["clientsecret"]), new tokencache());              authenticationresult authresult = await daemonclient.acquiretokenforclient(new string[] { graph_scope }, null);              // query list of users in tenant             httpclient client = new httpclient();              httprequestmessage request = new httprequestmessage(httpmethod.get, group_attachments_graph_query);              request.headers.authorization = new authenticationheadervalue("bearer", authresult.token);             httpresponsemessage response = await client.sendasync(request);              if (!response.issuccessstatuscode)             {                 var responsestring = await response.content.readasstringasync();                  console.writeline(response.statuscode + "content: " + responsestring);                 //throw new httpresponseexception(response.statuscode);             }              // record users in data store (note records first page of users)             string json = await response.content.readasstringasync();           }     } 


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -