[go-nuts] Consume RESTful API Endpoints within a golang application with webtoken

2020-03-15 Thread 'Ingo Oeser' via golang-nuts
I can only recommend 
https://pkg.go.dev/golang.org/x/oauth2/clientcredentials?tab=doc if you are 
implementing that.

Configure clientcredentials.Config and use the http.Client returned by the 
Client method of that Config to do all your http calls.

It manages all the token refreshing automatically and transparently for you and 
is pretty battle hardened already. 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/df2c6b50-1d45-4e6d-9c97-1d487a994c7e%40googlegroups.com.


Re: [go-nuts] Consume RESTful API Endpoints within a golang application with webtoken

2020-03-11 Thread 'Benjamin' via golang-nuts
Easy, Store the expired time in the token, and hash them.
When the expired time almost reach, use the old token to get a new token.


> On Mar 12, 2020, at 09:25, Renato Marcandier  
> wrote:
> 
> Hello guys,
> do you have any HelloWorld project in GO using RESTful to issue HTTP requests 
> from within a Golang application to remote RESTful/API with web token that 
> expires every 60 minutes and then consume any data that is returned?
> I am trying to get a simple HelloWorld. First, I need to do a POST to grab 
> the new token and after using this token to do a GET and see the response 
> with "Hello World!" using the following parameters:
> -
> POST:
> 
> Using:
> grant_type: password
> client_id: x
> client_secret: x
> username: x
> password: x
> 
> URL: 
> https://cloudsso.cisco.com/as/token.oauth2?grant_type=password_id=xx_secret==xxx=xx
>  
> 
> 
> Response:
> {
> "access_token": "tMqvXkR4wTvFwKUNUvMrNUXdzkjD",
> }
> 
> -
> GET:
> 
> Using: Bearer Token
> URL: https://api.cisco.com/hello 
> 
> Response:
> {"helloResponse":{"response":"Hello World!"}}
> 
> 
> Regards
> RG
> 
> -- 
> 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 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/CAGbJOOiT8fm7z6t5pNiFSmkXZy2KXs8Xdw-Cq0BkUD1CbUNExA%40mail.gmail.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 golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/4C76B950-358E-4E9D-ADE8-B681B7F2EC44%40icloud.com.


[go-nuts] Consume RESTful API Endpoints within a golang application with webtoken

2020-03-11 Thread Renato Marcandier
Hello guys,

do you have any HelloWorld project in GO using RESTful to issue HTTP
requests from within a Golang application to remote RESTful/API with web
token that expires every 60 minutes and then consume any data that is
returned?

I am trying to get a simple HelloWorld. First, I need to do a POST to grab
the new token and after using this token to do a GET and see the response
with "Hello World!" using the following parameters:

-

POST:


Using:

grant_type: password

client_id: x

client_secret: x

username: x

password: x


URL:
https://cloudsso.cisco.com/as/token.oauth2?grant_type=password_id=xx_secret==xxx=xx


Response:

{

"access_token": "tMqvXkR4wTvFwKUNUvMrNUXdzkjD",

}


-

GET:


Using: Bearer Token

URL: https://api.cisco.com/hello


Response:

{"helloResponse":{"response":"Hello World!"}}


Regards
RG

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAGbJOOiT8fm7z6t5pNiFSmkXZy2KXs8Xdw-Cq0BkUD1CbUNExA%40mail.gmail.com.