i'm trying use beta version of ms outlook mail rest app-only tokens requests doesn't work expected.
for example, folder hierarchy synchronization behaves v2.0 , doesn't work app-only tokens.
the app-only token works request. what's error get?
to call request app-only token, need specific user instead of me in document request below:
get https://outlook.office365.com/api/v2.0/users/userprincipalname/mailfolders
and app-token, use code below:
public static async task<string> gettokenbycert(string clientid, string tenant, string certthumbprint,string resource) { string authority = $"https://login.windows.net/{tenant}"; x509certificate2 cert = certhelper.findcert(certthumbprint); var certcred = new clientassertioncertificate(clientid, cert); var authcontext = new microsoft.identitymodel.clients.activedirectory.authenticationcontext(authority); authenticationresult result = null; try { result = await authcontext.acquiretokenasync(resource, certcred); } catch (exception ex) { } return result.accesstoken; }
Comments
Post a Comment