My web app was working great on sandbox. I changed all of my requests from https://sandbox-api.uber.com/v1/... to https://api.uber.com/v1/... and now I'm getting an error I've never seen before.
Here are the details of the error:
Status: 409
Code: fare_expired
Title: The fare has expired. Please get estimates again, confirm the new fare, and then re-request.
I can't find any documentation on Uber's site on this specific error. I know that surge pricing acceptance can expire and have to be reauthorized, but I'm getting this error on the very first ride request.
Has anybody else seen this error? Happy to share more details as needed.
This is my ruby code where I make the ride request to Uber:
#uber_ride = JSON.load(RestClient::Request.execute(
:method => :post,
:url => "https://api.uber.com/v1/requests",
:payload => '{"start_latitude":' + lat_start.to_s + ',"start_longitude":' + lng_start.to_s + ',"end_latitude":' + lat_end.to_s + ',"end_longitude":' + lng_end.to_s + ',"product_id":"' + #uberx_id.to_s + '","surge_confirmation_id":"' + surge_id.to_s + '"}',
:headers => {'Authorization' => 'Bearer ' + session[:request_token], :content_type => 'application/json'}
))
The way I resolved this error was by hitting the /V1/ESTIMATES/PRICE endpoint BEFORE the request endpoint. I think this error message stems from Uber wanting you to present an estimated price to the user before submitting a request on their behalf.
Related
I don't know what happened but within the last day or two my Uber API token is no longer working. My app hasn't changed in about 2 months and I have been using the same API keys for over 18 months now. Has something changed with Uber's API?
Upon doing the following products call:
https://api.uber.com/v1/products?cache_key=0.3082511832189301&latitude=27.8719024&longitude=-82.4946555
I began getting this error:
{message: "Invalid OAuth 2.0 credentials provided.", code: "unauthorized"}
Using AngluarJS, here is my code:
var confHeaders = {'Pragma':'no-cache', Expires: -1, 'Cache-Control':'no-cache,no-store,must-revalidate', Authorization: 'Token ' +clientToken} ;
var unique = Math.random() ;
return $http({url: "https://api.uber.com/v1/products" , cache:false,
headers: confHeaders ,
params: {cache_key:unique,latitude: startInfo.lat,longitude: startInfo.lon},
timeout:httpTimeout
}).then(function(response){
...
});
#staticmethod
def _google_url_shortener(original_url):
try:
data = json.dumps({'longUrl': original_url})
result = requests.post(conf.GoogleURL, headers={
'Content-Type': 'application/json'}, data=data)
shortened_url = result.json()['id']
return shortened_url
except Exception as e:
print('err {}'.format(e))
return original_url
I am using Google URL Shortener to make my URLs shorter, from google, it says 1,000,000 requests per day, unfortunately, I got 403 ERROR after 2500+ requests have been sent out. It doesn't help even I drop the request TPS to 0.5
Can anyone help?
I think TFS RESTful api has a bug. I am trying to access it using an Angular web app. Our TFS server is corporate internal. Here is my code:
var path = 'http://tfs.mycompany.com/tfs/mycompany/_apis/wit/queries?$depth=1&$expand=all&api-version=2.2';
var config = { withCredentials: true };
$http.get(path, config)
.then(function (response) {
$scope.resultList = response.data.d.results || [ response.data.d ];
$scope.message = 'Found ' + $scope.resultList.length + ' item' + ($scope.resultList.length == 1 ? '':'s');
}, function (response) {
$scope.resultList = [];
$scope.message = 'Error ' + response.status + ' ' + JSON.stringify(response.data);
});
The request goes to the server, and the server responds with OK 200. However, the browser (Chrome) blocks the data, and tells me:
A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header
when the credentials flag is true. Origin 'http://localhost' is therefore
not allowed access. The credentials mode of an XMLHttpRequest is controlled
by the withCredentials attribute.
The request headers have Origin:http://localhost
The response headers have Access-Control-Allow-Origin:*
Is there any way for me to tell TFS to not return * in the Access-Control-Allow-Origin? This seems like a serious bug in TFS, which renders the RESTful api practically useless for web apps!
You may check Cross-origin resource sharing (CORS) example below to add Authorization in your code:
$( document ).ready(function() {
$.ajax({
url: 'https://fabrikam.visualstudio.com/defaultcollection/_apis/projects?api-version=1.0',
dataType: 'json',
headers: {
'Authorization': 'Basic ' + btoa("" + ":" + myPatToken)
}
}).done(function( results ) {
console.log( results.value[0].id + " " + results.value[0].name );
});
});
Also, check this case to see whether it is helpful:
AJAX cross domain issue with Visual Studio Online REST API
I keep getting 403 from Intuit AggCat API in response to all requests except getInstitutions and getInstitutionDetails (they return correct data). Has anyone else experienced that?
Ruby code excerpt:
IntuitIdsAggcat.config(:issuer_id => "...")
IntuitIdsAggcat.config(:oauth_consumer_key => "...")
IntuitIdsAggcat.config(:oauth_consumer_secret => "...")
IntuitIdsAggcat.config(:certificate_path => "...")
IntuitIdsAggcat::Client::Services.delete_customer '1'
IntuitIdsAggcat::Client::Services.discover_and_add_accounts_with_credentials 14007, 1, { "onlineID" => "...", "passcode" => "..." }
IntuitIdsAggcat::Client::Services.get_customer_accounts 1
Response:
{:challenge_session_id=>nil, :challenge_node_id=>nil, :response_code=>"403", :response_xml=><UNDEFINED> ... </>}`
I am using https://github.com/rewardsummit/intuit_ids_aggcat
The documentation for that response code is located [here]: https://ipp.developer.intuit.com/index.php?title=0010_Intuit_Partner_Platform/0020_Aggregation_%26_Categorization_Apps/AggCat_API/0700_Error_Codes
It looks like the users credentials either changed or they are locked.
regards,
Jarred
Im trying to build a 'cheer action' for my app. It is a game in iPhone, so I want to post a 'welcome message' in the users wall (I will need 'public_stream' permission) and then invite his friends to visit my webpage.
Here my question.. I authenticate the user using:
_url = "http://www.facebook.com/dialog/oauth/?client_id=" + app_id + "&redirect_uri=" + app_net_folder + auth_response_uri + "&state=" + session_id;
I get response in my uri, and then I get the access_token, user_id, etc.
Then I post a message in his wall in this way:
_url = "https://www.facebook.com/dialog/apprequests?app_id=" + app_id;
_url += "&message=" + string_ToUrl(String_ToHTML(request_msg));
Now I want to invite his friends (using a multi friend list dialog). To do it, I can only use JavaScript FB.ui. In this way:
FB.init({appId : app_id, logging : false, frictionlessRequests: true, oauth : true});
FB.ui({method: 'apprequests', message: msg, title: title}, requestCallback);
When I do it, a window is opened asking me again for the user's login.. but my user has been already authenthicated. So I dont know how to say to FB in JavaScript that my user has been alredy authenthicated! (I even have the access_token, but I don't know how to use it in JavaScript functions).
Someone knows what am I doing wrong? or how to do those two actions asking just one time for the user's login?
Thanks!!
if you are already log in, you can get login user id using below code
var userId = FB.Facebook.apiClient.get_session().uid;
if(userId > 0 || userId != '')
{
alert('user is already log in');
}
hope it's helpful to you