403 AuthFailureError in Volley - android

I am having a very strange situation. I have a running script that makes JsonObjectRequest using Volley Singletone. The script has been working perfectly in domain example1.com. Recently I bought example2.com and hosted in the same hosting account. And when I copy all the php files as it is in the second domain, I am getting error "BasicNetwork.performRequest: Unexpected response code 403".
So, I have exactly same php files called using JsonObjectRequest and Volley Singletone working in example1.com, but not in example2.com. I have check the permission of the files in both domain, they are exactly same (644) and there is no htaccess in either of the domain.
I am stuck and don't understand what else I should check?
Any help will be highly appreciated.

Problem is with your server side php script - You can first try to test POST requests using some tool before implementing in your Android application:
If I performed a simple POST request (just using browser not Android) to your provided link I get following error:
403: Forbidden
403 Forbidden Forbidden You
don't have permission to access /mylibman_4_5.php on this server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request. Apache
Server at mylibrarymanager.com Port 80

Related

API works in browser but not in postman or app

All the API's work in the browser but none of them is working in my android app and postman.
Status:
In postman and in my app, error code received is:
500 Internal Server Error
I think your problem is csrf-token you can disabled it in
App\Http\Middleware\VerifyCsrfToken
and add your routes name in this array
$except = [] array.
It could be that postman is missing some request headers, cookies or session data. You could look into using Postman Interceptor. It's a tool which records requests made from Google Chrome and clones them to your Postman history. From that history tab you can simply replay the request, which will be an exact clone. Maybe that'll resolve the 500 errors you're getting.

Jhipster Jwt Authentication for Mobile API

I have a jHipster project with Jwt Authentication but I can't get it to work outside de webapp. I'm currently developping a Android application and the authentication process get harder than I expected.
Basically I'm sending the parameters of the LoginDTO, to UserJwtController#authorize ('/api/authenticate'). At first I was getting Unauthorized, both on Android or Postman (I'm using it to test the requests).
If I change the '/api' to permitAll, I'm getting 405, Request method 'POST' not supported.
EDIT
It was a wrong typo on Android :/
It works fine for me against /api/authenticate, so either you use wrong URL (e.g. /api/authorize) or your JSON payload is wrong. The only issue you could have is with CORS. You should consider testing with curl as it is easier than PostMan for reporting here what you really do and also the curl options are already built for you in JHipster swagger page.

Send POST request from Android to Symfony backend

I try to send POST requests (like forms) from my Android application to my Symfony backend but when I hit the 'Send' button for example, an Android FileNotFoundException ('http://192.168.1.84/1day-symfony/web/app_dev.php/api/request') is thrown. Maybe it is caused by the rewritten URL.
I do not know how to fix it...
Using Volley fixes the issue of the rewritten URLs.

Bad request when connecting to ASP.NET page on IIS from android application

I have a ASP.NET website deployed to IIS with a couple of ashx that returns JSONs to be consumed by an Android application.
I have implemented an authentication logic using Basic Authentication.
The problem: When accessed from Android, the server response is a 400 Bad request. The httperr log file says "400 - Hostname -".
It works when I try it out on localhost from Android emulator
It works when accessing the ashx file on the server from a browser
It works when replicating the call in Fiddler
(If I use Fiddler with the Android Emulator, the Response will be -1 (and looking in Fiddler at the raw data sent, it seems to loose the host from the url) - but this is another issue so don't dwell on that, i just thought I would mention it...)
Turns out my problem (and solution) was the same as in this thread:
HTTP POST request with authorization on android

Why does my django development server keep responding with 403, how do I allow POST?

So I have a django development server that I want to be the backend for my android app. For the time being, its I am just running the development server on my local machine.
I've been able to successfully retrieve data from the server, but I am now trying to POST data to the server through a JSON object, however I keep getting error code 403 in response. The method in my views.py file doesn't even get called, it just automatically response with 403. Heres what the server response looks like in the terminal.
[28/Nov/2011 17:58:40] "POST /createUser/ HTTP/1.1" 403 2326
Here is the url in my urls.py
url(r'^createUser/$', 'mydb.views.createUser'),
But I am always getting this 403 error, does anyone know why?
Possibly also important:
when I remove django.contrib.auth and django.contrib.contenttypes from INSTALLED_APPS I get a different print out from the server in the terminal: (error code 500 instead)
[28/Nov/2011 17:32:31] "POST /createUser/ HTTP/1.1" 500 82471
So I am thinking there is some sort of permissions issue going on.
For a quick fix, try adding #csrf_exempt decorator to the view:
from django.views.decorators.csrf import csrf_exempt
#csrf_exempt
def createUser(request):
That said, for a back end API, definitely read up on CSRF
I read the following link about CSRF tokens: docs.djangoproject.com/en/dev/ref/contrib/csrf
Then I turned off middleware since I am just on the localhost for the time being.

Categories

Resources