w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
AngularJs http get to PHP script returns the php code
This is a factory, for naming convention sake, you might want to rename it HttpRequestFactory app.factory('HttpRequestService', function($http, $q) { var HttpRequestService = { async: function() { var deferred = $q.defer(); $http.get('/test.php') .success(function (data, status, headers, config) { deferred.resolve(data); }) .error(function(data, status, headers, config){ deferred.reject("An error occured"); }); return deferred.promise; } }; return HttpRequestService; });

Categories : PHP

AngularJS: $routeProvider when resolve $http returns response obj instead of my obj
$http @returns {HttpPromise} Returns a {@link ng.$q promise} object with the standard then method and two http specific methods: success and error. The then method takes two arguments a success and an error callback which will be called with a response object. The success and error methods take a single argument - a function that will be called when the request succeeds or fails respectively. The arguments passed into these functions are destructured representation of the response object passed into the then method. The response object has these properties:

Categories : Javascript

AngularJS - refresh view after http request, $rootScope.apply returns $digest already in progress
Oh my ! You got the f** matter with AngularJS ! In fact you have to do a "safeApply" like that for example : $rootScope.safeApply = function(fn) { var phase = this.$root.$$phase; if(phase == '$apply' || phase == '$digest') { if(fn && (typeof(fn) === 'function')) { fn(); } } else { this.$apply(fn); } }; In AngularJS you can only have one $apply or $digest loop at the same time. For details on these loops look at the docs : http://docs.angularjs.org/guide/concepts It will explain what is the $apply loop and you'll understand a lot of things about the two-way-data-binding in AngularJS Hope it helps.

Categories : Http

LinkedIn OAuth returns wrong Accesstoken?
So typically when I finally posted my question I found this Custom OAuth client in MVC4 / DotNetOpenAuth - missing access token secret answer which will solve my problem and it seems it would not be possible to intercept the other token in another way.

Categories : C#

Python Linkedin API OAuth2 HTTP Error 401: Unauthorized
I wrote below code to Share Content on linkedin using OAuth 2.0 import requests import json def make_request(method, url, token ,data=None, params=None, headers=None, timeout=60): headers = {'x-li-format': 'json', 'Content-Type': 'application/json'} params = {} kw = dict(data=data, params=params, headers=headers, timeout=timeout) params.update({'oauth2_access_token': token}) return requests.request(method.upper(), url, **kw) def submit_share(comment, title, description, submitted_url, submitted_image_url, token): post = { 'comment': comment, 'content': { 'title': title, 'submitted-url': submitted_url, 'submitted-image-url': submitted_image_url, 'description': description }, 'visibi

Categories : Python

http/https mismatch with linkedin recommendations on a website
I had the same problem while integrating LinkeIn auth on my site. While it didn't stop the linkedin api from working, I was annoyed to see the error popping on the console. So I binded a listener to remove any iframe coming from "https://api.linkedin.com" before it loads. jQuery('body').bind("DOMSubtreeModified", function(evt) { var elemento=evt.delegateTarget.lastChild; if(elemento.tagName=='IFRAME') { if(elemento.src.indexOf('https://api.linkedin.com')!=-1) { jQuery('#'+elemento.id).remove(); } } }); Everything is still working.

Categories : Javascript

Django Authenticate returns None
Why don't you create a user like this: user = User.objects.create_user( username="whatever", email="whatever@some.com", password="password") user = authenticate( username="whatever",password="password")

Categories : Django

Authorization in RESTful HTTP API, 401 WWW-Authenticate
To answer your questions: How to deal with unauthorized requests? The way you described it is pretty much the recommended way for a RESTful service. As far as I can see there is absolutely nothing wrong with that. What WWW-Authenticate header should 401 responses supply? In general the WWW-Authenticate header tells the client what kind of authentication the server will accept. If the client makes an unauthorized request, which means he is sending a request with a missing or invalid Authorization header, the server will use WWW-Authenticate to tell the client what authentication scheme he will accept (i.e. Basic, Digest or OAuth) and for what realm. Imagine it like some kind of identification question or challenge on the part of the server, i.e. something like "Who are you?" or "Prove

Categories : Http

How to authenticate an http request that isn't POST?
Make a POST request when user logs in for the first time and generate a session code for that user on server and send it to the browser. Now you can send that session code from browser by putting it in your GET query url every time you query and thus you can authenticate the user on server.

Categories : Http

How to authenticate users either via HTTP Header or via parameters
Ok I figured out the answer for my question. According to the doc on http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Token.html for the HTTP Header authentication, if no token is found at all it returns nil. So the test on the params won't be executed at all. So I test the params before the HTTP header and let authenticate_or_request_with_http_token deal with the 401 unauthorized response. unless User.exists?(api_key: params[:api_key]) authenticate_or_request_with_http_token do |token, options| User.exists?(api_key: token) end end

Categories : Ruby On Rails

How do I get to authenticate and send xml through http in Go (golang) SOAP
If you are talking about HTTP Basic Auth, create a Request object and use the SetBasicAuth(username, password string) method. See this question for more information.

Categories : Go

Omniauth linkedin with Sinatra /auth/linkedin/callback?oauth_problem=user_refused
On a rails application, I solved the same issue by putting the following into my config/initializers/omniauth.rb. Please note that I redirect to a specific route for auth failures so that I can provide some hints on signing in with Linkedin: OmniAuth.config.on_failure do |env| message_key = env['omniauth.error.type'] origin_query_param = env['omniauth.origin'] ? "&origin=#{CGI.escape(env['omniauth.origin'])}" : "" strategy_name_query_param = env['omniauth.error.strategy'] ? "&strategy=#{env['omniauth.error.strategy'].name}" : "" extra_params = env['omniauth.params'] ? "&#{env['omniauth.params'].to_query}" : "" new_path = "/auth_failure?message=#{message_key}#{origin_query_param}#{strategy_name_query_param}#{extra_params}" Rack::Response.new(["302 Moved"

Categories : Ruby

how to share user authenticate login data between http and www
Except when there is a reason to have separate www and non-www domains, it's better to redirect the www of non-www domain to the other. Also, it's better for SEO. You can do this by adding this to your .htaccess file: RewriteEngine On rewritecond %{http_host} ^yoursite.com rewriteRule ^(.*) http://www.yoursite.com/$1 [R=301,L]

Categories : PHP

Authenticate Google Apps Script user via HTTP
You are going to have to do a little leg work on this one. Firstly, when you publish your apps script, make sure to change the "who has access to the app" to something like "only myself". Then you need to see what happens when you try to hit that URL from an external service without authenticating. There may be some help from the error codes you are likely to receive. I imagine you can then use the following documents to Authenticate for Google Services IN GENERAL. Then you will most likely have to pass a sessionID or Accesskey of some sort. I only have a brief understanding of OAuth, but I do imagine that you may be able to set up a more permanent connection between your other server and your particular Google Apps Script. I hope this helps. Jacob

Categories : Google Apps Script

Why does my ServiceStack AuthProvider never call Authenticate(), even when IsAuthorized() returns false?
This answer probably comes a bit late, but I just stumbled upon your question now. A few weeks before you asked your question, I tried to implement my own AuthProvider and had a similar problem: How to get ServiceStack authentication to work? (with iPhone clients) (near the bottom of the question, there's my MyBasicAuthProvider) In the end I found out what I did wrong, and I think you made the same mistake as I did: I needed to override TryAuthenticate instead of Authenticate. As soon as I changed that, my provider worked.

Categories : Authentication

How to renew linkedin oauth access token using linkedin-j?
The 'expires_in' field value can be saved and you could schedule the renewal process accordingly. I recently started using linkedin-j api, but POST/PUT methods weren't working with oAuth2.0. So had to switch back to oAuth1.0, wherein there is no problem of access token expiry.

Categories : Android

Authenticate http request with certificate in REST service (NOT SSL/HTTPS)
Are you using .net client to invoke Rest service? If yes you can attach certificate to HttpWebRequest request. request.Certificates.Add(certficate). check this link for configuring server for client certificate request You need to enable ssl to select Require client certificate. Other option is accept certificate in which case it will allow the user to access resource and you need to provide other way of authenticating the user if client does not present certificate. All these are valid only if accessing from sophisticated framework (like .net/Java). If you try to access from javascript I dont think you can attach client certificate. Only browser can send client certificate (Require client certificate setting) as part of normal http request. whatever option I mentioned require ssl commu

Categories : C#

Gitlab clone over http fails to authenticate from external network
I believe this is fixed in 5.3, so try updating. See: https://github.com/gitlabhq/gitlabhq/blob/master/CHANGELOG#L41 https://github.com/gitlabhq/gitlabhq/blob/master/config/gitlab.yml.example#L151

Categories : Http

Android Http Basic Authenticate Request from Ruby on Rails
Please visit this url. It is very useful for Ruby on Rails and Android Authentication.

Categories : Android

AngularJS authenticate once to use multiple apps
Let's start with the wrong answer, but that stick to how this problem is currently solved : often, developers relies on server-side authentication, considering auth a different application and a different problem than full-client side programming. Now if you want to do it only on the client side, it is still feasible, but you have to keep in mind that templates will always be accessible by a non-authenticated user. Here is an article about the subject and it's associated github repository. It does not rear multiple apps, but by tweaking this service you could achieve the trick. This solution use cookies as you mentionned. Here is a very relevant blog article that complete the answer to your question : what are the potential approaches. In short : use token.

Categories : Angularjs

How to proper authenticate an AngularJS client to the server
Thanks to the tip of lossleader I solved the problem. I removed the login() method, because I want the Java EE-Server to take care of authentication. To access secured areas the AngularJS webapp has to set the HTTP-Header correctly. In my case $http.defaults.headers.common['Authorization'] = 'Basic '; where username:password has to be Base64 encoded. After I set the headers correctly, no Password Prompt is shown and the AngularJS webapp can access the REST API.

Categories : Java

handling $http.get and $http.post errors in Angularjs
Response interceptors are attached during the config phase of an angularjs app. You can use them to globally respond to any $http request. Be aware, template files also use $http request, so you may wish to filter some requests in your interceptor to only the ones you wish to respond to. A good understanding of the promises pattern is needed to successfully use response interceptors. Heres an example of how they are used: angular.module('services') .config(function($httpProvider){ //Here we're adding our interceptor. $httpProvider.responseInterceptors.push('globalInterceptor'); }) //Here we define our interceptor .factory('globalInterceptor', function($q){ //When the interceptor runs, it is passed a promise object return function(promise){

Categories : Angularjs

Display LinkedIn profile photo and user profile using LinkedIn API
I found the solution for my question, it should change the LinkedIn API call to be: - (void)profileApiCall { // NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~"]; NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~:(id,first-name,last-name,industry,picture-url,location:(name),positions:(company:(name),title),specialties,date-of-birth,interests,languages)"]; OAMutableURLRequest *request = [[OAMutableURLRequest alloc] initWithURL:url consumer:oAuthLoginView.consumer token:oAuthLoginView.accessToken callback:nil signatureProvider:nil]; NSLog(@"the request is %@",request); [request setValue:@"json" forHTTPHeaderField:@"

Categories : Objective C

Neo4j returns HTTP 400
I'll take a stab at something that might help. Have you tried sending as a batch of separate statements? See: http://docs.neo4j.org/chunked/stable/rest-api-batch-ops.html This way you could parameterize it and just send them all at once: start n=node({destId}), oldFriend=node({oldFriend}) create unique n<-[:Comment {relProps}]-oldFriend And in the params use: {CreatedTime:635094700950000000}

Categories : C#

Why REST PUT returns HTTP/1.x 405 Method Not Allowed
PUT requires you to know the specific resource ID already - it is intended to REPLACE the content of the current record with the content of a new record (that you provide). If you are just creating a new record that has never existed before and you don't want to replace or overwrite anything else, you should use POST. From the website linked: There are two ways to add a row to a table: Using a PUT method we can write a resource to a specific URL, but to do this we must already know the primary key we want to insert it at (since the primary key forms part of the URL). The PUT method should be used to create or overwrite a known named resource. Using a POST method we can send a rows representation to a tables URL and get it to append it to itself. The POST method shoul

Categories : PHP

Writing async http returns in Nodejs
Async functions will never return something that has to fetched with async. getWebPageBody in your case returns undefined, and then later your callbacks happen. In synchronous programming you return a value. But in async, you provide it as an argument to a callback function. So instead, make your function accept a callback argument, and simply call it when you are done. var getWebPageBody = function(res, callback) { var pageRes = ""; res.setEncoding('utf8'); res.on('data', function(requestBody) { pageRes = requestBody; console.log('[ DEBUG ] BODY: ' + pageRes);

Categories : Node Js

Move audio player 5 second fast-rewind & fast-forward
Put below methods for forward and rewind player time - (IBAction)btnForwardClicked:(id)sender { int currentTime = [player currentTime]; [player setCurrentTime:currentTime+5]; } - (IBAction)btnBackwardClicked:(id)sender { int currentTime = [player currentTime]; [player setCurrentTime:currentTime-5]; } here player is avaudio player's object AVAudioPlayer *player;

Categories : Iphone

How to set routes for a controller in MVC. Always returns "HTTP Error 404.0 - Not Found"
I'm not sure your route is working beyond the default, as you're explicitly providing the parameters. Try registering your route in RouteConfig.cs http://www.jondavis.net/techblog/post/2012/06/23/ASPNET-MVC-4-Where-Have-All-The-Globalasax-Routes-Gone.aspx

Categories : Asp Net Mvc

What http status would tomcat returns during redeployment time?
Tomcat will return HTTP 404 while redeploying. But i suggest to restart Tomcat, because many applications has ClassLoader leak and after some hot redeploys Tomcat get PermGenSpace exception.

Categories : Apache

IIS Config HTTP OPTIONS returns 200 but with empty response
IIS has a default OPTIONSVerbHandler that might catch the request before MVC does. If you remove that handler, your application should handle the request and return the correct response. <system.webServer> <handlers> <remove name="OPTIONSVerbHandler" />

Categories : Asp Net

Check if a HTTP request returns 404 or page not found
It's possibile achieve that using curl. EDIT Add this to your functions.php: function wpcf_is_404( $url = null ){ $code = ''; if( is_null( $url ) ){ return false; }else{ $handle = curl_init($url); curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE); curl_exec($handle); $code = curl_getinfo($handle, CURLINFO_HTTP_CODE); if( $code == '404' ){ return true; }else{ return false; } curl_close($handle); } } and then make a call to wpcf_is_404(); in your template files or in your functions.php to test if the given url returns true ( 404 ) or false ( all other responses ) Hope it helps!

Categories : Wordpress

AngularJS with $http
If you put alert in success(), you will see it gets called. However, you'd better handle the error as well. function ($rootScope, $http) { return function (scope, element, attrs) { element.bind('click', function () { //fire off $http $http({ method: 'GET', url: attrs['url'] }).success(function (data, status) { console.log('called'); $rootScope.user_favourites = data.user_favourites }).error(function (data, status) { //error handling }); }); }; }); Demo

Categories : Angularjs

Web API POST method returns HTTP/1.1 500 Internal Server Error
The data in your post is not a valid JSON-object, which is what the model binder is expecting (Content-Type: application/json). {"iduser"="123456789","username"="orange"} Try replacing your = with : and see how you get on. Your code works on my machine with those alterations in the request. POST http://localhost:20377/api/test/Postuser HTTP/1.1 Host: localhost:20377 Connection: keep-alive Content-Length: 42 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 Origin: chrome-extension://fhjcajmcbmldlhcimfajhfbgofnpcjmb Content-Type: application/json Accept: */* Accept-Encoding: gzip,deflate,sdch Accept-Language: en-GB,en;q=0.8,en-US;q=0.6,nb;q=0.4,de;q=0.2 {"iduser":"123456789","username":"orange"}

Categories : Web Services

IE9 XmlHttpRequest returns 12019 error instead of HTTP/417 response code
If clearing the cache doesn't help, it's likely that this is related to how URLMon wraps certain HTTP error status codes; for instance IE9 and below would convert a HTTP/204 response into a bogus 1223 status code (see http://www.enhanceie.com/ie/bugs.asp) This problem was fixed in IE10 such that the server's response status is correctly returned to the script.

Categories : Jquery

Angularjs - Using $http on a HTTPS URL
You might need to tell it to send the cookie: In your config, DI $httpProvider and then set withCredentials to true: .config(function ($routeProvider, $httpProvider) { $httpProvider.defaults.withCredentials = true; //rest of route code Info on angularjs withCredentials: http://docs.angularjs.org/api/ng.$http Which links to the mozilla article: https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS?redirectlocale=en-US&redirectslug=HTTP_access_control#section_5

Categories : Javascript

AngularJS, $http and transformResponse
To get angular to not convert your data into an object you need to override the behavior of the default $httpProvider.defaults.transformResponse. It is actually an array of transformers. You could just set it to be empty: $http.defaults.transformResponse = []; Here is an example transformer I have used to convert 64-bit long ints to strings: function longsToStrings(response) { //console.log("transforming response"); var numbers = /("[^"]*":s*)(d{15,})([,}])/g; var newResponse = response.replace(numbers, "$1"$2"$3"); return newResponse; } To add a transformer to the default list, say ahead of the JSON deserializer, you can do this: $http.defaults.transformResponse.unshift(longsToStrings);

Categories : Javascript

AngularJS $http undefined
When using the bracket notation the dependency list before the function needs to match the services being injected into the function. You have an extra $location service in your EventsListController function so change this: .controller('EventListCtrl', ['$scope', '$http', function EventListController($scope, $location, $http) { // controller code goes here }]); to this: .controller('EventListCtrl', ['$scope', '$http', function EventListController($scope, $http) { // controller code goes here }]); The key change being: function EventListController($scope, $http) instead of function EventListController($scope, $location, $http)

Categories : Http

Angularjs autocomplete from $http
You need to write a controller with ng-change function in scope. In ng-change callback you do a call to server and update completions. Here is a stub (without $http as this is a plunk): HTML <!doctype html> <html ng-app="plunker"> <head> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script> <script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.4.0.js"></script> <script src="example.js"></script> <link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet"> </head> <body> <div class='container-fluid' ng-controller="TypeaheadCtrl"> <pre>Model: {

Categories : Angularjs

golang - library/package that returns json string from http request
There is nothing wrong it using existing system package and it fairly simple to retrieve json data over http in go package main import ( "encoding/json" "fmt" "net/http" ) func main() { var data struct { Items []struct { Name string Count int Is_required bool Is_moderator_only bool Has_synonyms bool } } r, _ := http.Get("https://api.stackexchange.com/2.2/tags?page=1&pagesize=100&order=desc&sort=popular&site=stackoverflow") defer r.Body.Close() dec := json.NewDecoder(r.Body) dec.Decode(&data) for _, item := range data.Items { fmt.Printf("%s = %d ", item.Name, item.Count) } } Output go run main.go jav

Categories : Json

Google Services OAuth requests returns HTTP 400 Bad Request Error
For anyone experiencing this issue, I've basically come to the conclusion that google hasn't interfaced calendar with their service accounts yet, and am using a refresh token to achieve similar results without having to log in all the time.

Categories : PHP



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.