Skip to content

Failed to get user with the graph service client #26

@NikaidouShinkus

Description

@NikaidouShinkus

I'm trying to get user with the graph service client:

import (
	"bytes"
	"encoding/json"
	"fmt"

	azure "github.com/microsoft/kiota/authentication/go/azure"
	msgraphsdkgo "github.com/microsoftgraph/msgraph-sdk-go"

	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
)

cred, _ := azidentity.NewClientSecretCredential(
		"<my-tenant-id>",
		"<my-client-id>",
		"<my-client-secret>",
		&azidentity.ClientSecretCredentialOptions{
			AuthorityHost: azidentity.AzureChina,
		})

auth, _ := azure.NewAzureIdentityAuthenticationProviderWithScopes(cred, []string{
	"https://microsoftgraph.chinacloudapi.cn/.default",
})


adapter, _ := msgraphsdkgo.NewGraphRequestAdapter(auth)

client := msgraphsdkgo.NewGraphServiceClient(adapter)
users, _ := client.Users().Get(nil)
fmt.Println(users)

it got nil:

<nil>

but the config worked when I user Postman:
image

So I read code and see in msgraphsdkgo.NewGraphServiceClient:
image
it's https://microsoftgraph.chinacloudapi.cn/v1.0 for Azure AD of China, and it seems that I can't change this value:
image

Thanks for your attention.

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions