Google OAuth - Incorrect JSON while Validating Access Token - json

I'm getting an access token from the Android SDK which I'm sending to the server. On the server side, I'm calling the following API to validate my token:
https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=<token here>
From Google, I'm getting the following response (partial response added):
{\"statusCode\":200,\"body\":\"{n \"issued_to\":
\"407408718192.apps.googleusercontent.com\",n \"audience\":
\"407408718192.apps.googleusercontent.com\",n \"user_id\":
\"110586055381870434283\",n \"scope\":
\"https://www.googleapis.com/auth/plus.login
https://www.googleapis.com/auth/plus.me"}
Unfortunately, this JSON is not parseable because of the backslashes & i'm not able to validate the token identity.
Is this a problem with the Google API or do I need to apply any regex?

Google sends back proper JSON without the slashes, being exactly the part that's inside the "body" element of the output that you paste (well without the slashes).
So your Node.js HTTP client is wrapping it with the HTTP status code element and puts in the slashes as well, so your clients need convert back from that on its own.

Related

When use AWS Lambda to process mails from mailgun, can't get mails in JSON format

What I am tried to do is to have a lambda function proccess emails forwarded by mailgun.
So far, I have setup mailgun's route so it will forward emails to a AWS api gateway, then the api gateway triggers a lambda function.
The problem comes when I try to process the mail, instead of getting a pretty Json that I am expecting inside the lambda's event.body, I m getting raw post form data like
--cff4e6b3-a3a4-4131-bb8d-90a73f1b4c36\r\nContent-Disposition: form-data; name=\"Content-Type\"\r\n\r\nmultipart/mixed; boundary=\"001a1140216cee404d05440c49e7\"\r\n--cff4e6b3-a3a4-4131-bb8d-90a73f1b4c36\r\nContent-Disposition: form-data; name=\"Date\"\r\n\r\nTue, 20 Dec 2016 13:40:53 +1300\r\n--cff4e6b3-a3a4-4131-bb8d-90a73f1b4c36\r\nContent ......
My question is, what should I do to get the JSON version of the forwarded emails in lambda?
Not sure if you ever came to a solution, but I have this working with the following settings.
Setup your API Gateway method to use "Use Lambda Proxy integration"
In your lambda (I use node.js) use busboy to work through the multi-part submission from mailgun. (use this post for help with busboy Busboy help)
Make sure that any code you are going to execute after all busboy is complete is executed in the 'finish' portion of the busboy code.
This suggests that your mailgun route is misconfigured and ends with a MIME request:
When you specify a URL of your application as a route destination through a forward() action, Mailgun will perform an HTTP POST request into it using one of two following formats:
Fully parsed: Mailgun will parse the message, transcode it into UTF-8 encoding, process attachments, and attempt to separate quoted parts from the actual message. This is the preferred option.
Raw MIME: message is posted as-is. In this case you are responsible for parsing MIME. To receive raw MIME messages, the destination URL must end with mime
From Receiving Messages via HTTP through a forward() action

Return OAuth2 Error as JSON instead of XML

I am implementing an RESTful Webservice which returns every content formatted as JSON. I am also using Spring OAuth2, but all error messages like invalid access token etc are returned in XML format. How can I return these OAuth2 errors as JSON?
By the way, the access tokens are returned as JSON String.
We have faced the same problem.
After hours and hours of configuring it on server side we have found better way to migrate this nuisance.
Error messages for OAuth2 for Spring defaults to xml but with one simple trick you can change them to JSON: by sending Accept: application/json in request headers.
Hope I helped a bit.

Sending comma seperated string in json request to rest client web service

I am using restclient or postman for my web service
Here in I have to send request json :
{"wallpost_id":3338,"share_text_msg":"job fair in usa","logged_in_user_id":37,"receiver_id":19,12}
where i want to send comma separated values, but rest client does not
allow me to use the above format
Therefore I am using Postman to solve the purpose and it is
working fine in postman. But my team at android end want to use
it x-www-form-urlencoded tab of postman, but there the problem
arises. Please suggest that how can i send such format in rest
client.
19,12 is not a valid number. If you quote that as a string (e.g. "19,12") does it work?

cannot get document id using box view api

In my app, after get "https://dl.boxcloud.com/*" url and send it to the View API, I receive this error:
{
message: "JSON parse error - No JSON object could be decoded"
type: "error"
request_id: "3ef12abcaf7a4c5abab5fb0d3959255e"
}
you can use this chrome extension to recreate this error
https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo
I tried with the other rest clients and it work correctly. Except in my app and the extension above.
I tried with the other rest clients and it work correctly. Except in my app and the extension above.
If this is the case, it's likely that the client you're using isn't actually sending properly formatted JSON. One way to debug this would be to output the raw HTTP request the client is sending and ensuring that it's actually sending the JSON properly.

wso2 esb json post method blank query parameter handling

I converted JSON (client) to SOAP (back end) through ESB Proxy Service and it is working fine.
URL "https://someurl.com/json/"
The problem is that I am trying to call from another batch process application (Mirth) and it is adding "?" end of the URL changing the URL to "https://someurl.com/json?" How can I get rid of the "?" character?
This article contains information on how to customize URLs.
This is also possible using Script mediator - these can also be used for URL transformations.