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.
Related
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.
I am using play-games-plugin-for-unity to authenticate my Unity (Android) game with Google Play Games and pass authentication code to my Python (Flask) server.
While client code works well, I am getting redirect_uri_mismatch error when sending authentication request from my server (which I am running locally).
I have debugged my server code and confirmed that:
I am getting auth code from the client correctly
My redirect_uri is set to postmessage (default value set by oauth2client)
I tried removing "Authorized redirect URIs" (which it created by default when I added linked web app to my game in Google Play Games Console).
Although this seems to be a common problem, I failed to find any examples/references to resolve this while using play-games-plugin-for-unity. As far as I can tell, I does not seem to send any redirect_uris but I can't tell for sure without rebuilding native Android plugin and trying to debug it. I feel like I am missing something simple here.
Here is my server code:
from oauth2client import client
credentials = client.credentials_from_code(LINKED_WEB_APP_CLIENT_ID,
LINKED_WEB_APP_CLIENT_SECRET,
['https://www.googleapis.com/auth/games'],
server_auth_code)
After looking through clientserverskeleton Java example, I found out that passing "" (empty string!!) as redirect_uri works:
from oauth2client import client
credentials = client.credentials_from_code(LINKED_WEB_APP_CLIENT_ID,
LINKED_WEB_APP_CLIENT_SECRET,
['https://www.googleapis.com/auth/games'],
server_auth_code,
redirect_uri="")
I am currently learning django and android. I created a REST API for my backend. The endpoints are working since I can GET/POST with Postman, Insomnia, and httpie. However, if I try it with my android app it gives the response 'Bad Request'. I've been working on it for many hours now. Could someone explain to me why is this happening?
![1]: http://imgur.com/a/NF1oY
![2]: http://imgur.com/a/UG06U
Solved. I was using a lightweight server by django to run my api. Found out about gunicorn.
I have created REST service according to this: http://www.asp.net/web-api/overview/older-versions/creating-a-web-api-that-supports-crud-operations
tutorial and a android client according to this: http://www.techrepublic.com/blog/software-engineer/calling-restful-services-from-your-android-app/
I changed the service to receive the json messages, and the connection string to the same that works in the browser, with 10.0.2.2 instead of localhost(according to one of the advices in stackoverflow) - in the browser it works perfectly. When I try to test it on the emulator I get the 400 bad request error. Maybe this is totally wrong way of approaching this, I am confused - would you kindly show me the error in the implementation or the tutorial that could help me with consuming the rest api with android client?
I have packaged a Sencha Touch 2 app with PhoneGap for Android. I can't get the ajax requests to work on my native application. When I handle the request through the browser on http://mydomain.com/mysenchaapp/android/assets/www/ it works fine, however, when I run my app through the emulator as a native app my request fails. I think it would be helpful if I could get fiddler to work on handling native apps' request as well, but I haven't been able to figure that out either. Any help is appreciated.
On a native application you can use cross-domain get requests without using JSONP. I got it to work. My problem accessing the servlet was another issue.
You can't use Ajax for Cross-Domain GET requests, you should use JSONP instead. Take a look at the documentation for Ext.data.JsonP.request(), You can however use Ajax to make a post if i'm not mistaken. This comes in handy when uploading something like a base64 string (which is too big for a GET request)