office365 - How to get AppKey using Microsoft Graph API -
i'm creating new application using
post https://graph.microsoft.com/beta/applications
i can appid back, can't find way appkey. access app later using application credentials.
update: send password credential during application creation:
newappobj.passwordcredentials = new list<aobj.azurepasswordcredential>(){ new aobj.azurepasswordcredential() { customkeyidentifier = "t1rexhnmuumvqimnbpkirw==", keyid = guid.newguid().tostring(), value = "wgjbf8vg3gm1xrgpc43fvtio7scptgwh0jd6cjird40dcx3kp8lmlcdcrrepbridi4cxw1ocnsqjqxozx+oiuw==", startdate ="2016-06-01t13:59:30z",// datetimeoffset.utcnow, enddate = "2017-06-02t13:59:30z"//datetimeoffset.utcnow.addyears(2) } };
when generate authorization token using secret key set before value, response back, when trying use call microsoftgraph api:
{ "error": { "code": "authorization_identitynotfound", "message": "the identity of calling application not established.", "innererror": { "request-id": "42d3f97d-5ccb-4680-a6c2-dceb160d19c7", "date": "2016-06-02t21:03:31" } } }
when create secret key manually via azure portal, api call works fine.
update 2:
so, turned out post create application didn't create underlying serviceprincipal object. had create after application created.
var serviceprincipal = o365outlookclient.getserviceprincipalforapp(inonboardingtoken, createdappobj.appid); if (serviceprincipal== null || serviceprincipal.appid==null) { var serviceprincipalobj = new aobj.azureserviceprincipal(); serviceprincipalobj.appid = createdappobj.appid; serviceprincipalobj.displayname = createdappobj.displayname; serviceprincipalobj.accountenabled = true; var serviceprincipaljson = o365outlookclient.postserviceprincipalsync(inonboardingtoken, serviceprincipalobj); }
application password credentials need generated , set (either when create application, or later patch
application). can generating strong random value, creating passwordcredential , adding passwordcredentials
collection:
{ /* ... */ "passwordcredentials": [ { "customkeyidentifier": "t1rexhnmuumvqimnbpkirw==", "enddate": "2016-06-02t13:59:30z", "keyid": "e4003ae7-15be-487a-92d7-5d75aafdb4dc", "startdate": "2016-06-02t13:59:30z", "value": "wgjbf8vg3gm1xrgpc43fvtio7scptgwh0jd6cjird40dcx3kp8lmlcdcrrepbridi4cxw1ocnsqjqxozx+oiuw==" } ] /* ... */ }
customkeyidentifier
base64-encoded byte array (can whatever want), keyid
newly-generated guid, , startdate
, enddate
dates in password credential valid. actual secret key stored in value
.