I'm using gradle-play-publisher library to upload my app to Google Play, but I get error 401 Unauthorized when executing the publishing task.
My dev account at Google Play and service account at Dev Console are set up. Play API is enabled.
As I see from build logs, the first request sent is:
POST https://accounts.google.com/o/oauth2/token
I get 200 OK and the following json:
{
"access_token" : "< some value here>",
"token_type" : "Bearer",
"expires_in" : 3600
}
Then the next request is sent:
POST https://www.googleapis.com/androidpublisher/v2/applications/< my app's package name here>/edits
First of all, I noticed this header among others:
Authorization: <Not Logged>
And second, I get this error as a response
401 Unauthorized
WWW-Authenticate: Bearer realm="https://accounts.google.com/", error=invalid_token
Has anyone faced the same issue? Everything seems to be set up correctly, so I have no idea what went wrong. Thank you.
Your error means that
server responded with 401 (Unauthorized) status code but failed to provide a single auth challenge (WWW-Authenticate header) thus making it impossible for HttpClient to automatically recover from the authentication failure.
Check your HTTP POST request in you application which might expect
some short of credentials in the HTML form
I hope that you are already testing your rest API(url) by using POSTMAN google chrome extension.
Now,if your rest api works fine then consider about using that in your code, step by step try to figure out the following
server implementation is wrong or client side implementation wrong or url
parameters are wrong
check for <uses-permission android:name="android.permission.INTERNET" /> in your
AndroidManifest.xml
Related
I am trying to implement Huawei in App Purchase kit to my application.
The request I am sending to the server is here:
request {"purchaseToken":"0000017343ec91821b076fd75f71103a5a85595d2dfd245d708fd6058e676f857792b83622c7fd51x434e.1.100059717","productId":"1007"}
I am following this guide here : https://developer.huawei.com/consumer/en/codelab/HMSInAppPurchase/index.html#0
I am following the same steps but
I am getting an error message from server which says :
result: {"responseCode":"6","subErrCode":"211","responseMessage":"6-211-authorization format invalid"}
Which part I might be doing wrong?
In the error you are getting, it says "authorization format invalid". This means your ignature verification data format is invalid. The possible errors might be :
The token in the request header is not encrypted in Base64 mode.
The character string APPAT is not appended before the access token for authorization. The correct access token is similar to APPAT:thisIsAppAtVaule.
for more information, please check : https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/iap-FAQ
You are facing issue in server side. Kindly go through the given link to know more about In App Purchase server side and client side.
In-App Purchase Article Develioper Forum:
Client side : https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201255229704010231&fid=0101187876626530001
Server side : https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201273064244120101&fid=0101187876626530001
In-App Purchase Github Link :
Client side: https://github.com/DTSE-India-Community/HMS-In-App-Purchase-Kit
Server side:
https://github.com/DTSE-India-Community/Huawei-In-App-Purchase-And-Push-Kit-Server_Side-Implementation
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'm using google place api to develop a mobile application.
The Http request I sent was:
https://maps.googleapis.com/maps/api/place/autocomplete/json?sensor=true&key=KEY&components=country:uk&input=hu
But when I sent HTTP request to the Google server, it replies OVER_QUERY_LIMIT:
{
"predictions" : [],
"status" : "OVER_QUERY_LIMIT"
}
I have checked the instruction provided by Google and Android document, and also I have checked the usage of the requests from reports in the Google Console. But I found the used request is only 3, and the request/sec is 0.0017.
Could anyone provide some help on it? Thanks very much!
Oh...I have fixed up my error.
The reason was that I was using a public-shared API_Key by mistake, so sometimes I could get the result, but sometimes couldn't.
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.
Android I am using jTwitter
Twitter my_twiter = new Twitter("my_user_name","my_pass");
my_twiter.setStatus("hello world");
line 2 throws
winterwell.jtwitter.TwitterException$E403: Forbidden http://twitter.com/statuses/update.json (my_user_name)
what does that mean ??
One reason Twitter will return a 403 error is if you repeatedly post the same status message. That's probably what you've encountered here.
Try adding a random number to your test code, e.g.
my_twiter.setStatus("hello world "+new Random().nextInt(1000));
By the way, I see you're using the username/password login method. Twitter have announced they're switching that off - I think at the end of August. You may want to switch to OAuth. See the JTwitter homepage for details: http://www.winterwell.com/software/jtwitter.php
403 Forbidden: The request is understood, but it has been refused. An accompanying error message will explain why. This code is used when requests are being denied due to update limits.
Statuses over 140 characters will also cause a 403. But since you are just doing "hello world" that shouldn't be the case. The response body will contain a detailed error message.