Skip to content

Question about client_credentials #940

Answered by jeevatkm
MaheshVelankar asked this question in Q&A
Discussion options

You must be logged in to vote

Using clientcredentials package in the Resty is simple.

clientCredCfg := &Config{ /* values ... */ }
client := resty.NewWithClient(clientCredCfg.Client(context.Background()))

// start using resty client ...

However, there is a catch in the next part of the question. i.e., using CA Cert. As per the GoDoc of clientcredentials#Config.Client

The returned Client and its Transport should not be modified.

So this is no-go route for your use case.


I would suggest using the following approach.

Example using Resty v2.16.2

clientCredCfg := &clientcredentials.Config{ /* values ... */ }

client := resty.New()

// add custom auth request middleware
client.OnBeforeRequest(func(c *resty.Client, req *r…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jeevatkm
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #939 on January 04, 2025 07:32.