Skip to content

Commit

Permalink
azuread_client_config: return an error is object_id is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
manicminer committed Dec 16, 2020
1 parent 408f76d commit 14b1fa8
Showing 1 changed file with 4 additions and 3 deletions.
Expand Up @@ -2,6 +2,7 @@ package serviceprincipals

import (
"context"
"errors"
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand All @@ -14,9 +15,9 @@ import (
func clientConfigDataSourceReadMsGraph(_ context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(*clients.Client)

objectId := ""
if client.Claims.ObjectId != "" {
objectId = client.Claims.ObjectId
objectId := client.Claims.ObjectId
if client.Claims.ObjectId == "" {
return tf.ErrorDiagPathF(errors.New("oid claim in access token is empty"), "object_id", "Could not determine object ID of authenticated principal")
}

d.SetId(fmt.Sprintf("%s-%s-%s", client.TenantID, client.ClientID, objectId))
Expand Down

0 comments on commit 14b1fa8

Please sign in to comment.