Hi, 
I am trying to get the oauth2 token from an internal token provider. I am 
using this to get the oauth2 token- 

package main

import (
  "golang.org/x/oauth2/clientcredentials"
  "golang.org/x/net/context"
  "fmt"
  "golang.org/x/oauth2"
  "crypto/tls"
  "net/http"
)

func main(){

  // this should match whatever service has given you
  // client credential access
  config := clientcredentials.Config{
    ClientID: "xxxxxx",
    ClientSecret: "xxxxxxxxxx",
    TokenURL: "https://10.2.54.203/api/oauth";,
  }

  tr := &http.Transport{
        TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
  }


  // you can modify the client (for example ignoring bad certs or otherwise)
  // by modifying the context
  httpClient := &http.Client{Transport:tr}
  ctx := context.Background()
  ctx = context.WithValue(ctx, oauth2.HTTPClient,httpClient)

  tok,err := config.Token(ctx)

   if err != nil{
    panic(err)
  }

  fmt.Println(tok)

}
I get the following error - Response: 
{"type":"http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html","title":"invalid_client","status":400,"detail":"The
 
client credentials are invalid"}

But I know that my credentials are correct as I am able to get the access 
token using the curl -k command with the same credentials.

When I use the default HTTP client(without insecure TLS verify set to 
true), I get an error saying no IP is present in the SANS certificate.

Can anyone help me out?


-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to