Help with Oauth2 "grant_type=client_credentials"

543 views
Skip to first unread message

tmack8080

unread,
Feb 11, 2020, 6:56:34 PM2/11/20
to golang-nuts

Hi,

 

I'm not a programmer.

I have this working in PowerShell.

 

Requirement:

Query hardware vendor web APIs, using the device serial number, for device warranty status.

 

The vendors require that the "client_id" and "client_secret", as well as the "grant_type=client_credentials" be passed.

 

All of the documentation I've located discusses using Oauth for 3rd party authentication. Obviously, not what I'm doing. Can anyone point me to a tutorial that uses "client_credentials"? I've not found one.

 

I tried using the example on the authO website; no luck: https://auth0.com/docs/api-auth/tutorials/client-credentials (you have select Go from the list of languages). When printing out the 'payload' variable I see it appended with a {0 -1} and I'm wondering if that's the problem:


&{client_id=xxxxxxxxxx&client_secret=xxxxxxxxxx&grant_type=client_credentials 0 -1}

{

  "error":"invalid_request",

  "error_description":"Missing or duplicate parameters"

}

 

Thanks in advance.

andrey mirtchovski

unread,
Feb 11, 2020, 7:43:34 PM2/11/20
to tmack8080, golang-nuts
i would strongly advise against implementing advice received online
for something as important as auth. my suggestion is to work with curl
from the command line (examples are given on the webpage you linked)
until you have the process working. implementing that afterwards using
http.Client will be more or less trivial.

that said, you may be missing a call to SetBasicAuth with the client
id and secret, or sourcing a JWT beforehand from /oauth/token
> --
> 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...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/64214d0a-1191-4f46-8bfd-2c716cdb2d3f%40googlegroups.com.

Chris Broadfoot

unread,
Feb 11, 2020, 7:45:56 PM2/11/20
to andrey mirtchovski, tmack8080, golang-nuts

tmack8080

unread,
Feb 11, 2020, 10:08:09 PM2/11/20
to golang-nuts
This looks like what I need.

Thanks Chris.
> To unsubscribe from this group and stop receiving emails from it, send an email to golan...@googlegroups.com.

> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/64214d0a-1191-4f46-8bfd-2c716cdb2d3f%40googlegroups.com.

--
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 golan...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages