-
Notifications
You must be signed in to change notification settings - Fork 850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update service principal credentials #699
Comments
Thanks Chessman, @mcardosos will be talking a look at this |
It seems that Keys in SDK are Certificates on Portal and Keys on Portal are Passwords in SDK... |
Hello @chessman ! What you say is correct, keys in the SDK are certificates in the portal and the passwords are the keys. cliAAD := graphrbac.NewApplicationsClient(tenantID)
cliAAD.Authorizer = graphAuth
list, err := cliAAD.ListPasswordCredentials(appObjID)
if err != nil {
panic(err)
}
passwords := *list.Value
passwords = append(passwords, graphrbac.PasswordCredential{
StartDate: &date.Time{time.Now()},
EndDate: &date.Time{time.Now().Add(30 * 24 * time.Hour)},
Value: to.StringPtr("some-value"),
})
_, err = cliAAD.UpdatePasswordCredentials(appObjID, graphrbac.PasswordCredentialsUpdateParameters{
Value: &passwords,
})
if err != nil {
panic(err)
} |
@mcardosos Thanks for your reply! Are you sure that passwords can be added only to applications? I tried to add a password to service principal and it works. Furthermore, it is mentioned in docs (PATCH method on passwordCredentials): |
@chessman Adding passwords to service principal is equivalent to adding them to the application :) |
@mcardosos But if I have a multi-tenant application and I'm adding a password to service principal, will it be added for all tenants or just for the tenant of service principal? |
If you have a multi-tenant application, then you need to add the password/key to the application and not to the service principal. The application is centralized (together with the app's credentials). The service principal (which is an application instance) references back to the application (and its credentials). As the app developer, you then just need to manage the app's credentials in one place. In general, whether you have a single-tenant or multi-tenant application, you should add the credentials (password/key/secret) to the application. It can be added to the service principal too (per the API), but it's only intended for certain scenarios. NOTE: If you have questions about multi-tenant model etc, please feel free to send questions to stack overflow (and tag [azure-active-directory]) |
Closing this issue since stack overflow is the best place to send questions about AAD. |
I have a multi-tenant native application and corresponding service principal. I'm trying to add a key to the service principal to have app-only access to Graph API (BTW, I'm not sure it is proper scenario). This is an example:
It fails with an error:
Response:
It looks like
KeyCredential
contains a fieldcustomKeyIdentifier
which doesn't exist in Go structure (the field has type Edm.Binary):https://msdn.microsoft.com/Library/Azure/Ad/Graph/api/entity-and-complex-type-reference#keycredential-type
Nevertheless, the meaning of this field is not clear. How to use
UpdateKeyCredentials
?The text was updated successfully, but these errors were encountered: