Duplicate grant_type parameter Uber API - oauth-2.0

I'm trying to get OAuth access to Uber, using Cortana's Connected account.
All necessary for authentication data, a.k.a. auth url, token url, client secret, etc. was taken from Uber API description and passed to Cortana, so she must do all low-level job for me.
But when I'm trying to login in to uber, I receving such answer:
"error": "The token response status code was not 200.",
"serviceRequest": {
"Host": "login.uber.com",
"Headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic VXF6cGVzeWVwYXFPZDBrc0FsUTh3U0dTHFvb2k6TFg0TWFhVDRwU0NFNlM3ZDJVMGJSdlU0VnJhTnRncFJPVlo4UkNqQg=="
},
"Method": "POST",
"Path": "/oauth/v2/token",
"UrlParameters": {
"redirect_uri": "https://www.bing.com/agents/oauth",
"grant_type": "authorization_code",
"code": "some code private here :)"
},
"PostData": "redirect_uri=https%3a%2f%2fwww.bing.com%2fagents%2foauth&grant_type=authorization_code&code=SOME_AUTHORIZATION_CODE"
},
"serviceResponse": {
"Headers": {
"Connection": "keep-alive",
"Pragma": "no-cache",
"X-Uber-App": "login",
"Strict-Transport-Security": "max-age=604800",
"X-Content-Type-Options": "nosniff",
"X-XSS-Protection": "1; mode=block",
"Cache-Control": "no-store",
"Date": "Sat, 28 Oct 2017 10:30:57 GMT",
"Set-Cookie": "session=421370309da06baf_59f45c61.RKb0a7144yyiV9HlZgssA5ZvSqE; Domain=login.uber.com; Secure; HttpOnly; Path=/",
"Server": "nginx",
"Content-Length": "84",
"Content-Type": "application/json"
},
"StatusCode": 400,
"ResponseData": "{\"error_description\": \"Duplicate grant_type parameter.\", \"error\": \"invalid_request\"}"
},
As you can see, in property ResponseData I have an error: Duplicate grant_type parameter.
What could it be?

Do you need to repeat the auth parameters for the token request as URL params when they are included in the POST data. I am assuming that "some code private here :)" and SOME_AUTHORIZATION_CODE are the same.

Related

Microsoft Graph - Education user batch request not returning a value property

Running batch requests against most Microsoft Graph API endpoints returns a object with a value property like this:
{
"id": "2",
"status": 200,
"headers": {
"Cache-Control": "no-cache",
"x-ms-resource-unit": "1",
"OData-Version": "4.0",
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
},
"body": {
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,displayName,student,teacher)",
"value": [
{
"id": "ebe6297c-1f76-484e-9616-5e8e6be6098e",
"displayName": "Adele Vance"
}
]
}
},
However running a batch request against /education/user/{userId} gives me:
{
"id": "1",
"status": 200,
"headers": {
"Cache-Control": "no-cache",
"OData-Version": "4.0",
"Content-Type": "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8"
},
"body": {
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#education/users(id,displayName,student,teacher)/$entity",
"id": "ebe6297c-1f76-484e-9616-5e8e6be6098e",
"displayName": "Adele Vance"
}
}
Without any value property.
This looks like a bug. Not sure how to proceed.
Best regards,
Oskar
It depends on the endpoint you are calling in batch request.
For endpoints returning a collection, the batch response contains "value": [{..},..] in body...collection of objects.
For endpoints (like your endpoint GET /education/users/{id} that return single object, the batch response contains the object.

Power Automate / Twilio : HTTP POST Error

I'm not sure what I've messed up, but I'm receiving this error when attempting to send a POST request from Power Automate to a Twilio Flow.
Was able to trigger the Twilio Flow from PowerShell, but cannot replicate on Power Automate.
{
"code": 20001,
"message": "Missing required parameter To in the post body",
"more_info": "https://www.twilio.com/docs/errors/20001",
"status": 400
}
input
output
http request post
This ended up working for me.
Change Content-Type value to
application/x-www-form-urlencoded; charset=utf-8
Change Body value to
To=%2B12223334444&From=%2B15556667777
12223334444 = Send To #
15556667777 = Send From # (Twilio Phone # assigned the Flow)
Re: Using HTTP POST with Twilio
INPUT
{
"uri": "https://studio.twilio.com/v2/Flows/##################################/Executions",
"method": "POST",
"headers": {
"content-type": "application/x-www-form-urlencoded; charset=utf-8"
},
"authentication": {
"username": "**********************************",
"password": "*sanitized*",
"type": "Basic"
},
"body": "To=%2B12223334444&From=%2B15556667777"
}
OUTPUT
{
"statusCode": 201,
"headers": {
"Connection": "keep-alive",
"Twilio-Concurrent-Requests": "1",
"Twilio-Request-Id": "##################################",
"Twilio-Request-Duration": "0.055",
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "Accept, Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since",
"Access-Control-Allow-Methods": "GET, POST, DELETE, OPTIONS",
"Access-Control-Expose-Headers": "ETag",
"Access-Control-Allow-Credentials": "true",
"X-Shenanigans": "none",
"X-Home-Region": "us1",
"X-API-Domain": "studio.twilio.com",
"Strict-Transport-Security": "max-age=31536000",
"Date": "Tue, 08 Jun 2021 14:04:24 GMT",
"X-Powered-By": "AT-5000",
"Content-Length": "707",
"Content-Type": "application/json"
},
"body": {
"status": "active",
"date_updated": null,
"contact_channel_address": "+12223334444",
"account_sid": ""**********************************",",
"url": "https://studio.twilio.com/v2/Flows/##################################/Executions/##################################",
"context": {},
"sid": "##################################",
"date_created": "2021-06-08T14:04:23Z",
"flow_sid": "##################################",
"links": {
"steps": "https://studio.twilio.com/v2/Flows/##################################/Executions/##################################/Steps",
"execution_context": "https://studio.twilio.com/v2/Flows/##################################/Executions/##################################/Context"
}
}
}

Rails api is not returning access-token and client to external url via devise token auth

I'm having an issue with devise_token_auth returning a client and access-token back to my front end. It works fine in my test environment and I get the expected results. But in my dev environment I am using a external url. This is the response I get when I create a session:
Object {
"config": Object {
"adapter": [Function xhrAdapter],
"baseURL": "http://93ae6a5f.ngrok.io/api/v1",
"data": "{\"email\":\"test#gmail.com\",\"password\":\"password\"}",
"headers": Object {
"Accept": "application/json",
"Content-Type": "application/json",
},
"maxContentLength": -1,
"method": "post",
"timeout": 0,
"transformRequest": Object {
"0": [Function transformRequest],
},
"transformResponse": Object {
"0": [Function transformResponse],
},
"url": "http://93ae6a5f.ngrok.io/api/v1/auth/sign_in",
"validateStatus": [Function validateStatus],
"xsrfCookieName": "XSRF-TOKEN",
"xsrfHeaderName": "X-XSRF-TOKEN",
},
"data": Object {
"data": Object {
"allow_password_change": false,
"email": "test#gmail.com",
"id": 1,
"image": null,
"name": null,
"nickname": null,
"provider": "email",
"uid": "test#gmail.com",
"username": null,
},
},
"duration": 731,
"headers": Object {
"cache-control": "public, max-age=0",
"content-type": "application/json; charset=utf-8",
"etag": "W/\"0fa41fc630ddb8ffc9b9f9f9b90849b5\"",
"transfer-encoding": "chunked",
"vary": "Origin",
"x-request-id": "320d3bd6-7e94-48b4-8e14-fe434d593b6a",
"x-runtime": "0.303548",
},
"ok": true,
"originalError": null,
"problem": null,
"status": 200,
}
I went through the devise_token_auth docs and have already added this to my application.rb
config.middleware.use Rack::Cors do
allow do
origins '*'
resource '*',
headers: :any,
expose: ['access-token', 'expiry', 'token-type', 'uid', 'client'],
methods: [:get, :post, :options, :delete, :put]
end
end
Anyone have any thoughts on how to get this working?
Did you add the following to your controller?
include DeviseTokenAuth::Concerns::SetUserByToken

Ruby on Rails get body object from fcm response

I have implemented fcm for push notification in windows ruby on rails. but I'm getting response of send() that is in following format. I need only body attribute's value.I'm pretty new to ruby on rails. please guide how can i achieve it.
fcm = FCM.new(server_key)
options = {
priority: "high",
# collapse_key: "updated_score",
notification: {
title: "Hi Android",
body: "Hi, Worked perfectly"
}
}
response = fcm.send([device_token], options)
This is my response
{
"success": true,
"data": {
"body": "{\"multicast_id\":8218758506962978728,\"success\":1,\"failure\":0,\"canonical_ids\":0,\"results\":[{\"message_id\":\"0:1514875371230492%ebb60861ebb60861\"}]}",
"headers": {
"content-type": [
"application/json; charset=UTF-8"
],
"date": [
"Tue, 02 Jan 2018 06:42:51 GMT"
],
"expires": [
"Tue, 02 Jan 2018 06:42:51 GMT"
],
"cache-control": [
"private, max-age=0"
],
"x-content-type-options": [
"nosniff"
],
"x-frame-options": [
"SAMEORIGIN"
],
"x-xss-protection": [
"1; mode=block"
],
"server": [
"GSE"
],
"alt-svc": [
"hq=\":443\"; ma=2592000; quic=51303431; quic=51303339; quic=51303338; quic=51303337; quic=51303335,quic=\":443\"; ma=2592000; v=\"41,39,38,37,35\""
],
"accept-ranges": [
"none"
],
"vary": [
"Accept-Encoding"
],
"connection": [
"close"
]
},
"status_code": 200,
"response": "success",
"canonical_ids": [],
"not_registered_ids": []
}
}
You can follow ruby OpenStruct library, it's something like this
object = JSON.parse(response, object_class: OpenStruct)
Then you can find based on object value and very nicely explain here
Hope to help
suppose your response is hash
body = hash[:data][:body].gsub(/[\"]/,"")
and out put will be like this: -
"{multicast_id:8218758506962978728,success:1,failure:0,canonical_ids:0,results:[{message_id:0:1514875371230492%ebb60861ebb60861}]}"

callFunctionInBackground doesn't work properly when the Parse iOS sdk was updated to 1.14

I updated the library from 1:12 to 1.14.2.
Now when I call a function in the Cloud Code, the fetch of the User is undefined.
The function call:
[PFCloud callFunctionInBackground:#"getListOfItems"
withParameters:nil
block:^(NSArray *result, NSError *error) {...
The iOS console log of user:
user <PFUser: 0x7bd910f0, objectId: qiW9i8rQCN, localId: (null)> {
ACL = "<PFACL: 0x7bc18890>";...
The response of Cloud code:
error: Error generating response. [TypeError: Cannot read property 'fetch' of undefined]
The log of the request:
{
"params": {},
"master": false,
"installationId": "xxx",
"log": {
"appId": "xxx"
},
"headers": {
"host": "xxx",
"connection": "close",
"user-agent": "xxx",
"x-parse-app-display-version": "1.0",
"accept": "*/*",
"x-parse-application-id": "xxx",
"accept-language": "en-us",
"x-parse-client-key": "xxx",
"x-parse-os-version": "10.0 (15G31)",
"x-parse-app-build-version": "1",
"x-parse-client-version": "i1.14.2",
"x-parse-installation-id": "xxx",
"accept-encoding": "gzip, deflate",
"x-request-id": "xxx",
"x-forwarded-for": "2.35.93.203",
"x-forwarded-proto": "http",
"x-forwarded-port": "80",
"via": "1.1 vegur",
"connect-time": "1",
"x-request-start": "xxx",
"total-route-time": "0",
"content-length": "0"
},
"functionName": "getListOfItems"
}
the log of user inside the Cloud code function:
undefined
If I go back to version 1.12 I have no problem
I found the problem. Is a iOs 10 simulator bug.
https://openradar.appspot.com/27844971

Resources