Apologies, I am not a top level developer and reading all the github docs and SDK’s is making me cross-eyed…
Could anyone provide a functional example of using Oath2 in a GoLang app? I have the basics, but I am quite unsure about the layout and where to put things…
So far I have this…
package main
import (
"context"
"fmt"
"github.com/okta/okta-sdk-golang/v2/okta"
)
func main() {
ctx := context.TODO()
ctx, client, err := okta.NewClient(ctx,
okta.WithOrgUrl("https://mycompany.okta.com"),
okta.WithAuthorizationMode("PrivateKey"),
okta.WithClientId("{myClientId}"),
okta.WithScopes([]string{"'okta.groups.read','okta.users.read','okta.groups.manage'"}),
okta.WithPrivateKey("{private_key}"),
okta.WithPrivateKeyId("{private key id}"), //needed if Okta service application has more then a single JWK registered
)
if err != nil {
fmt.Printf("Error: %v\n", err)
}
fmt.Printf("Context: %+v\n Client: %+v\n", ctx, client)
user, resp, err := client.User.GetUser(ctx, "{UserId|Username|Email}")
if err != nil {
fmt.Printf("Error Getting User: %v\n", err)
}
fmt.Printf("User: %+v\n Response: %+v\n\n", user, resp)
}