1

I am attempting to instantiate a client, based on the sample https://github.com/okta/okta-sdk-golang?tab=readme-ov-file#get-an-application. No matter what I do I always get:

a 401 Unauthorized Error.

The response is very limited. Anyone know what I am doing wrong? I get the token and use the application name of thisIsMyApplication.

package main

import (
    "context"
    "encoding/json"
    "fmt"
    "net/http"

    "github.com/okta/okta-sdk-golang/v5/okta"
)
    func main() {
            token := "bearerTokenFromOktaServer"
        
            // okta
            config, err := okta.NewConfiguration(
                okta.WithOrgUrl("https:oktaServer/oauth2/default/v1/token"),
                okta.WithToken(token),
            )
            if err != nil {
                fmt.Printf("Error: %v\n", err)
            }
            client := okta.NewAPIClient(config)
        
            application, resp, err := client.ApplicationAPI.GetApplication(client.GetConfig().Context, "thisIsMyApplication").Execute()
            if err != nil {
                fmt.Printf("Error getting application: %v\n", err)
            }
            fmt.Printf("Application: %+v\n Response: %+v\n\n", application, resp)
    }

The Response:

DAP server listening at: 127.0.0.1:56207
Type 'dlv help' for list of commands.
Error getting application: 401 Unauthorized
Application: <nil>
 Response: &{Response:0xc0001dc630 cli:0xc000202108 pg:0xc00011a000}
2
  • 1
    How does VSCode play into all of this? Commented Oct 19 at 17:15
  • Sometimes IDE challenges occur. Thank you for your feedback. @MarkM Commented Nov 3 at 22:09

1 Answer 1

0

Marking this as closed as using a different IDE provided a valid response object for me to dig deeper into. Thanks for your help everyone!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.