You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am unable to create a new Application with included KeyCredential due to seeming json serialization issues.
When I dig in with the debugger, I see the returned response from the API:
Expected property 'type_escaped' is not present on resource of type 'KeyCredential'
The following is a sample snippet which I used to repro this issue. Some values will have to be adjusted, of course :)
package main
import (
"fmt""github.com/Azure/azure-sdk-for-go/sdk/azidentity"
a "github.com/microsoft/kiota/authentication/go/azure"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go""github.com/microsoftgraph/msgraph-sdk-go/applications""github.com/microsoftgraph/msgraph-sdk-go/models/microsoft/graph""io/ioutil""log"
)
funcmain() {
_, pemBytes:=getPEMBytes()
cert, key, _:=azidentity.ParseCertificates(pemBytes, nil)
cred, _:=azidentity.NewClientCertificateCredential("my-tenant-id", "my-client-id",
cert, key, &azidentity.ClientCertificateCredentialOptions{})
auth, _:=a.NewAzureIdentityAuthenticationProviderWithScopes(cred, []string{".default"})
adapter, _:=msgraphsdk.NewGraphRequestAdapter(auth)
client:=msgraphsdk.NewGraphServiceClient(adapter)
managedApp:=graph.NewApplication()
n:="my-test-application"managedApp.SetDisplayName(&n)
managedAppKeyCred:=graph.NewKeyCredential()
keyBytes, _:=ioutil.ReadFile("new-app-credential.crt")
managedAppKeyCred.SetKey(keyBytes)
managedAppKeyCred.SetDisplayName(&n)
t:="AsymmetricX509Cert"managedAppKeyCred.SetType_escaped(&t)
u:="Verify"managedAppKeyCred.SetUsage(&u)
managedApp.SetKeyCredentials([]graph.KeyCredential{*managedAppKeyCred})
options:= applications.ApplicationsRequestBuilderPostOptions{
Body: managedApp,
}
result, err:=client.Applications().Post(&options)
iferr!=nil {
log.Fatal(err)
}
fmt.Printf("yay: %s", *result.GetAppId()) // note that in current state, this panics since the API returns an error but the SDK does not handle it (I'm aware this is a known issue)
}
I have just re-run go get -u and retested and this error persists.
go get -u
go: downloading golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71
go get: upgraded github.com/microsoft/kiota/abstractions/go v0.0.0-20211201125630-3501743a5dc5 => v0.0.0-20211203190524-b3aa0a7d4445
go get: upgraded github.com/microsoft/kiota/http/go/nethttp v0.0.0-20211130101617-a4871ba0f35f => v0.0.0-20211203190524-b3aa0a7d4445
go get: upgraded github.com/microsoft/kiota/serialization/go/json v0.0.0-20211112084539-17ac73ffdc7c => v0.0.0-20211203190524-b3aa0a7d4445
go get: upgraded github.com/microsoftgraph/msgraph-sdk-go-core v0.0.4 => v0.0.5
go get: upgraded github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 => v0.0.0-20210911075715-681adbf594b8
go get: upgraded golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 => v0.0.0-20211202192323-5770296d904e
go get: upgraded golang.org/x/net v0.0.0-20211123203042-d83791d6bcd9 => v0.0.0-20211205041911-012df41ee64c
go get: upgraded golang.org/x/sys v0.0.0-20210423082822-04245dca01da => v0.0.0-20211205182925-97ca703d548d
The text was updated successfully, but these errors were encountered:
This is caused by a bug in the generator. I've authored microsoft/kiota#926 to address this.
I've also kicked new generation PRs to reflect the changes in the SDK #51.
Once the pull requests get merged, this issue will be closed, then just run go get -u at the root of your project to get the update.
I am unable to create a new Application with included KeyCredential due to seeming json serialization issues.
When I dig in with the debugger, I see the returned response from the API:
The following is a sample snippet which I used to repro this issue. Some values will have to be adjusted, of course :)
I have just re-run
go get -u
and retested and this error persists.The text was updated successfully, but these errors were encountered: