I successfully authenticated to google play developer rest api and I am getting also the refresh token but I can figure out how to make an edit requests.
I have method signature at the following link:
https://developers.google.com/android-publisher/api-ref/edits/insert
I added the following header
Authorization:{{token_type}} {{access_token}}
but i cant figure out where to put the package name:
POST https://www.googleapis.com/androidpublisher/v2/applications/packageName/edits
I putted packageName like above using get and also as post parameter and in both cases i am encountered "404 not found" error.
Please help.
You can try
POST https://www.googleapis.com/androidpublisher/v2/applications/edits?id = packageid && expiryTimeSeconds = 20
GET https://www.googleapis.com/androidpublisher/v2/applications/**packageName**/edits/**editId**
according to
https://developers.google.com/android-publisher/api-ref/edits#methods
Please verify if you have followed all steps for authentication and authorization as shown here.
Since you are not getting 401 or 403, you might be sending the token correctly.
To call the api:
put your package name as a path paramters and specify the edit resource in the body. Please note that the edit resource is ignored but needs to be provided.
send your request like this:
POST https://www.googleapis.com/androidpublisher/v2/applications/yourPackageNameHere/edits
in the body:
{
"id": "abcd",
"expiryTimeSeconds": "asd"
}
make sure u provide content type in header as well.
Authorization is also required in the headers as you mentioned.
Hope this helps. :)
Related
I want to change data on a server via a put request, but I always get a 401 [no body] error. The response looks like the following:
I do not really understand why I get this error, because my body is not empty. My code looks like this and the values seem to be okay too. Does anyone have any idea what I'm doing wrong?
Postman Update:
The values are different right now (consent and authorisation) since its basically a new request but the values were correct before too so this change should not make a difference.
Looks like you are simply passing invalid authorization header, or maybe not passing it at all.
What happens is that you make a RestTemplate exchange call, then you get 401 from that request, and Spring propagates it and returns 500 - Internal Server Error, because there is no error handling in place.
EDIT: According to your screenshots, you are not replacing your path variables. Update the way you build your URL as listed below.
Map<String, String> pathVars = new HashMap<>(2);
pathVars.put("consent-id", consentId);
pathVars.put("authorisation-id", authorisationId);
UriComponents uri = UriComponentsBuilder.fromUri(mainLink)
.path("consents/{consent-id}/authorizations/{authorisation-id}")
.buildAndExpand(pathVars);
Verify if your authorization-id is correct
if the token has a type for example Bearer you must write so:
"Authorization": "Bearer rrdedzfdgf........."
and make sure that there is only one space between Bearer and the token
Often the problem comes from the browser locally;
if your site is online, save the part and deploy the last modifications of the site and make the test
otherwise if it is a mobile application test it on a smartphone and not a browser;
in case none of this works, do it with your backend, it works with this
I had a problem where the I would add an extra character to a password. And Insomnia(Or Postman) would return a JSON response from the server along with a 401 HTTP status code. But when I did the same thing inside a springboot app, when using catch(HttpServerErrorException e){System.out.prinln(e.getMessage());} the e.getMessage would have [no body]. I think that is a feature built in the HttpServerErrorException class where it doesn't provide the body for security purposes. Since whoever is requesting is not authorized they should not have access to it.
my ask at bottom.
i made a web api services with uses Bearer Token Authentication, seems work fine, how did i make this decision ;
1-when i use jquery
var loginObject = {
username: $("#userName").val(), // id
password: $("#password").val(), // pass
grant_type: "password"
};
$.post("http://localhost:60000/getToken", loginObject, function (result) {...}
//results come with token.. its fine at html side thankful for jquery
2- when post with postman, still works when i use x-www-form-urlencoded.
Works Fine Picture 1
BUT.. when i try post with fiddler : Fiddler Error (400)
I GET {"error":"unsupported_grant_type"} error.
there is the error. I cant get it, i going to use this web api for my android application, when im trying to get connection with volley, same error again.
Android throw error too :
Android Error (400)
I'am asking for you, how can i solve this problem. thanks all.
before create this question, i looked almost all error question like this. everyone just sayin : put the "content-type: app/x-ww..." , you can see i put this.
PHOTOS UPDATE :
1- Works Fine Picture 1 (Postman(app/x-www-form-urlencoded)) :https://ibb.co/dzZf29
2- Fiddler Error (400) : https://ibb.co/gomGaU
3- Android Error (400) : https://ibb.co/gi8UvU
(Add) 4- Postman (raw) (400) : http://prntscr.com/ktkl5b
the last add photo you can see, even postman the raw option, gives this error.
The error occurs only in Fiddler which means the problem is the way you are passing the data on it. Instead of passing and object try putting the data in the request body as an URL:
grantType=password&username=admin&password=123
I am trying to run POST method to get the access token using REST Assured Code. But it is returning 404 error. My code is as below.
POSTMAN Configuration as below same trying to replicate using Rest Assured
Method : POST
Authorization tab:
Type : Basic Auth
UserName : ABCD
Passsowrd : Test#1234
Body Tab :
Selecting "application/x-www-form-urlencode" Radio Button
Key : grant_type Value : Client_Credentials
Key : Scope value : ABCDAPI
given().auth().basic("Username Here","Password type here")
.header("Authorization", "Basic T1VUUkVBQ0hfQVBJX0NMSUVOVDpIWmRwREwydkR5UE5iQmtvWEdxSkFpK1Qxa08yWSszNndxQXhoYTVXUWhZPQ==n")
.header("Content-Type","application/x-www-form-urlencoded")
.contentType("application/x-www-form-urlencoded")
.body("[{\"grant_type\":\"client_credentials\"}]")
.body("[{\"scope\":\"ABCDpi\"}]").when()
.post("https://ABCD.KLM.id.XYZ-Cloud.net/oauth2/access_token?realm=PQR")
.then().contentType("").statusCode(200);
I am also attaching the screenshot of Postman where it is working enter image description here
Before trying the below code give yourself some time to look here.
Also application/x-www-form-urlencoded has its POST variables stored as key-value pairs in the body.
given().auth().basic(username, password)
.header("Content-Type","application/x-www-form-urlencoded")
.formParam("grant_type", "client_credentials")
.formParam("scope", "ABCDpi")
.post("https://ABCD.KLM.id.XYZ-Cloud.net/oauth2/access_token?realm=PQR")
.then().contentType("").statusCode(200);
I was seeing your code problem with a problem like yours. And I think discovering one solution for our problems.
It might work if you change the follow lines:
.body("[{\"grant_type\":\"client_credentials\"}]")
.body("[{\"scope\":\"ABCDpi\"}]").when()
for this:
.body("grant_type=client_credentials&scope=ABCDpi")
I hope having being helpfull.
I'm trying to implement this code. https://developers.google.com/drive/web/credentials#retrieve_oauth_20_credentials
I have my client id and client_secrets json for webapps, because I'm extracting some values from a spreadsheet, everything is ok and I already have spreadsheet's data in my application. But my question is How can I make to re-use that authorization code multiple times?, because I have to extract more data from that spreadsheet, my URL is http://localhost:8080/cluster/?state=/profile&code=xxxxxxx but for example when I try to refresh that page this error appears.
An error occurred: com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request
{
"error" : "invalid_grant",
"error_description" : "Code was already redeemed."
}
I have the same implementation of the url, but the only difference is I changed this methods storeCredentials(userId, credentials) - getStoredCredentials(userId) and put that values into a db table.
So, How can I implement 'exchange authorization code'? and how can I link my application to the new url?
Thanks for your help! :D
First at all, following the protocol the authorization code MUST BE used once, so the auth server must invalidate it after the first use.
If you want to use it for another part of your implementation, you can save it, use it and send a 302 redirect to your other page witch use your getStoredCredentials method
When i am trying to get data from facebook using graph api, i am getting this error,
{"error":
{"message":"(#803) Some of the aliases you requested do not exist: 124186682456_10151302011177457&access_token=REMOVED_ACCESS_TOKEN",
"type":"OAuthException",
"code":803}}
Can anyone help me in how to solve this problem.
Thanks in advance...
If that is an accurate representation of the error you're receiving, you're incorrectly appending the access token after a & character instead of a ?.
You need to use ? for the start of the query string, and & to separate the parameters inside the query string
e.g.
https://graph.facebook.com/124186682456_10151302011177457?access_token=ACCESS_TOKEN
Placement of access_token parameter immediately after ? has nothing to do with issue...
It could be that your URL is littered with %20 or similar stuff.
I got this error when trying a test example from Facebook API documentation, at first I have read highest voted answer, but moving access_token parameter immediately after ? didn't work, I then inspected URL more closely and found some of encoded spaces %20 that were stuck to parameter fields and some others, removing which fixed the issue.
try following URL (just replace access_token parameter with yours)
https://graph.facebook.com/search?type=place&fields=name,checkins,picture&q=cafe¢er=40.7304,-73.9921&distance=1000&access_token=[YOUR_ACCESS_TOKEN]
If it works look for problem in Facebook parameter names
Hope this saves you some time.
This was happening for me with the Instagram content publishing API which also rides off the facebook graph api. It seems to happen when something is wrong with the API URL you are trying to send to Facebook via GET request.
In my case, something was happening in my code causing the user_id and access_token to not be passed to the URL before trying to query the graph API.