oauth token request errors with "missing required parameter 'client_id'", [closed] - go

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 9 months ago.
Improve this question
I'm trying to get a token from squares oauth. I can successfuly get the code but when i try to get the token i receive the error "missing required parameter 'client_id'".
I can successfully get a token from postman but not sure why oauth2.Exchange is not passing all info to the oauth server when I try to do it programmatically.
here is a gist of my oauth2.Config object: https://gist.github.com/yshuman1/dedaead8568e695df7a06f86cd986c2d
here is a gist of my failing callback function:
https://gist.github.com/yshuman1/2b496e0fe698a5a0df087c60f4583677
Here is a gist of the redirect & callback functions as well as the oauth2.Config object: https://gist.github.com/yshuman1/b3c472978a4b1b73d6668dfe583f440f
In the callback gist, i also attempted passing in context.TODO() instead of context.Background().
any advice would be appreciated!
I've tried passing the missing items in but not sure what to do to get it done correctly.
I expect to receive a oath token back but dont. I'm getting the error
{
"message": "missing required parameter 'client_id'",
"type": "bad_request.missing_parameter"
}

i ended up solving this by replacing the .Exchange method used to obtain a token with a simple http.POST request to obtain it.

Set the parameter as
{"client_id":client_id}
Pass this JSON object as parameter.

Related

How to do a REST POST with Grafana AJAX panel?

I have a SpringBoot API with a POST end-point.
Trying to make a call to end-point from Grafana AJAX panel
It seems to be hitting the end-point but error occurs complaining about missing body.
error: "Bad Request" message: "Required request body is missing: public org.springframework.http.ResponseEntity status: 400
But the request has indeed a body.
Have been looking for possible POST examples for hrs now but no joy, e.g.
https://community.grafana.com/t/using-ajax-plugin-to-make-rest-call/6674
Any tips or solutions would be much appreciated.
Asked this same question on Grafana support forum.
Turns out the plugin/panel in question does not support POST with body.
Indeed, it looks like POST JSON data to backend is not currently supported. There seem to be two related issues here:
https://github.com/ryantxu/ajax-panel/issues/48
https://github.com/ryantxu/ajax-panel/issues/13
You're welcome to share your thoughts there, it looks like this feature request has been added as a future enhancement but I am not sure when that work will be completed. In the meantime, you may need to forego using the AJAX Plugin.
So it's basically useless as my backend API end-point requires a body.
try the new JSON API plugin
https://grafana.com/grafana/plugins/marcusolsson-json-datasource/?tab=changelog
or AjaxPanel plugin for more control

Getting error "Tokens cannot be shared. Please create a new token" in jmeter

I am passing a token that I have received while using the logging API in Http Header Manager as "Authorization : Bearer 'the token that I received'" in Jmeter and then testing another API which needs that token. It's going fine when I am running the request for one thread(user). But as soon as I'm increasing the no. of threads to 2 or 3, I am not able to get a response as it says, "Tokens cannot be shared. Please create a new token". Is there any way where I can login for two users and get different tokens and then pass the respective tokens for those two users separately to perform different tasks. And can this process be automated as I am trying to test for multiple users? Thanks in advance.
My Test Plan Looks like this:
Test Plan
My Http Header Manager Looks Like this:
enter image description here
My Regular Expression Extractor Looks Like this:
enter image description here
If I receive my token response like this
{
"token":"eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJwc2VuMSIsImV4cCI6MTUyNjYzMDA4MywiaXAiOiIxMjcuMC4wLjEifQ.k85RfQgOF2EiCzjVcmcRLgroHMCGb8P1a_Voi4mwzDEMQ3i2xUvNR6sHrHMO05k-b1MKsMBaxxuA-xiZe78_Xw"
}
What should my regular expression be like?
Am I following the procedures properly?
I tried to mimic your request and it seems like your regular expression extractor is not under the Login request and hence it is causing issue.
Try to put it under login instead at the same level as shown below:-
I hope it solves your problem, but if not, do share the error logs as I can see there are some errors reported in the top right hand "yellow" warning sign.

Intuit Customer Account Data (CAD) SAML Assertion returning Ambiguous Error Message

I am trying to obtain oauth tokens in order to use the CAD API, however, I keep getting this error:
Signature on SAML token is INVALID commentary: [Verification against Static Certificate not supported in this scenario.
Since they dont have an NPM or NodeJS I have started to create one, however, I am getting hung up on the SAML assertion request. So far I have ported over this ruby gem for making the saml request to get the new oauth token which is found here:
https://github.com/cloocher/aggcat/blob/master/lib/aggcat/base.rb (line 70) def saml_message...
My first stab at this is not neat, but I'm just trying to verify I can make a SAML request with NodeJS and get a response back containing oauth token.
My source code for this NodeJS script can be found at:
https://github.com/britztopher/intuit-cad/blob/master/server/saml2.js
And the Intuit documentation for making this request can be found here:
Intuits CAD Doc which is lacking any kind of sample of what is needed to produce the assertion message.
If any clarification is needed please comment, as I am just trying to jump this first hurdle.
OK, so after cloning the aggcat repo for the ruby script and modifying the template for the assertion message to use constants instead of variables then comparing the that assertion message to the one my script was generating I finally found the reason why this was failing. To make sure the sha1 digest was the same and the signature was the same I had to make the assertion messages were the same.
The reason for failure was that sample Assertion Sample in the documentation is wrong all over the place:
https://developer.intuit.com/docs/0020_customeraccountdata/009_using_customeraccountdata/0010_gettingstarted/0025_making_your_first_connection/saml_assertion_sample
There are spaces missing and the one thing that got me was this element:
This is not a terminating element and needs a closing tag. For example:
In addition, the xml doc type () is not needed either.
After all this aggravation with intuit's developer documentation, I decided to save everyone the trouble of trying to follow it to confusion, and made an NPM module called intuit-cad, which builds the SAML assertion and performs all the authentication in order for you to make clean API calls easily. Also, this module is built on top of promises, which make error handling and callback hell prevention a breeze. In addition to the library I have a simple blog post about it here: intuit-cad blog post

Error while getting acess token from IBM Connections

I am able to get authorization token, but getting error at access Token, These are the steps I am doing now,
1.Obtain the code:
https://{host}/oauth2/endpoint/connectionsProvider/authorize?response_type=code&client_id=sample_application&redirect_uri=http://{host}
I got back something like:
http://{host}/?code=XMQPNpxCxkRCfIXMFbWiTQVD4PcM11
2.Try to get access token using: POST method:
POST https://{host}/oauth2/endpoint/connectionsProvider/token?grant_type=authorization_code&redirect_uri=http://{host}&client_id=sample_application&client_secret=pIEaHOQ6odz0Vr9fKTmiS0NgQF2uGAUDl2i9ZHS38qE7TGZD2nn3RcSl2bEI
With payload data as: code=XMQPNpxCxkRCfIXMFbWiTQVD4PcM11
In the 2nd steps only I am getting error.
Please advice me.
-WillSteel
Resolved the issue the problem was the header we were sending was MediaType.APPLICATION_JSON but the token end point api expects MediaType.APPLICATION_FORM_URLENCODED, so by changing the header the oauth flow worked.

laravel-apidoc-generator + dingo api error "The token could not be parsed from the request"

Trying to generate API documentation via laravel-apidoc-generator, and get the following error:
I tried to use actAsUserId and header options and got the same error.
I have the same problem, and still have, but you can try to send authorization token via headers, and if that doesn't work, try to send the token as Query String Parameter. Neither of those work for me...

Resources