I am completely stumped by this. I have the following Facebook App Access Token registered for my app:
|
And then I try to GET the following URL: (Fake token underneath)
https://graph.facebook.com/<user-id>/likes?access_token=<number>|<hash>
String accessToken = "258443224256787|dsK3fffe7g-rejponkVlfwef3GenVng6Y";
WS.url("https://graph.facebook.com/" + socialUser.id.id + "/likes?access_token="+accessToken)
accessToken = "258443224256787" + URLEncoder.encode("|") + "dsK3ks7g-dsK3fffe7g-rejponkVlfwef3GenVng6Y";
I get the following error message:
{"error":{"message":"An access token is required to request this
resource.","type":"OAuthException","code":104}}
When I use it in the Graph API explorer tool however, I get no errors! I think the problem might be that I don't know how to use the pipe symbol in my URLs (tried Googling for hours without success - attempted URLEncoder.encodre to no avail).
Help please! :-)
(I'm using Java Play! 2)
Edit I should say that when I debug my link I get: "%7C" instead of pipe, due to the URLEncoder.
Edit 2 It also works when I post the URL directly into the browser.
Edit 3 Added URLEncoder-code
Turns out that WS.url() didn't accept my query parameters unless I used url().setQueryParameters() which solved the problem. :-)
Related
As part of learning how to integrate OneLogin SSO in my ColdFusion app I pulled this git repo -
https://github.com/GiancarloGomez/ColdFusion-OneLogin and set up locally. But, while sending the auth request to OneLogin we are getting an error message saying "We're sorry, but something went wrong.
We've been notified about this issue and we'll take a look at it shortly."
I could not find the root cause of this issue. Appreciate your timely help on this.
Configuration on OneLogin looks like below. Note that consumer URL I modified to http://127.0.0.1:8500/coldfusion-onelogin/consume.cfm instead of actual format mentioned (http://127.0.0.1:8500/coldfusion-onelogin/consume/) in the YouTube video provided in the readme file of this git repo. I had tried changing the consumer URL format as this http://127.0.0.1:8500/coldfusion-onelogin/consume/ but we are still getting the error message.
Access Tab in OneLogin looks like below,
Below is the code which sends auth request to OneLogin.
<cfscript>
try{
// used to encode string - chose to use Java version just in case CF did not encode correctly
// encodeForURL appears to work but to keep the same as the samples from OneLogin I will use the Java reference
urlEncoder = createObject("java","java.net.URLEncoder");
// the appSettings object contain application specific settings used by the SAML library
appSettings = createObject("java","com.onelogin.AppSettings");
// set the URL of the consume file for this app. The SAML Response will be posted to this URL
appSettings.setAssertionConsumerServiceUrl(request.company.getConsumeUrl());
// set the issuer of the authentication request. This would usually be the URL of the issuing web application
appSettings.setIssuer(request.company.getIssuerUrl());
// the accSettings object contains settings specific to the users account.
accSettings = createObject("java","com.onelogin.AccountSettings");
// The URL at the Identity Provider where to the authentication request should be sent
accSettings.setIdpSsoTargetUrl("https://app.onelogin.com/saml/signon/" & request.company.getIssuerID());
// Generate an AuthRequest and send it to the identity provider
authReq = createObject("java","com.onelogin.saml.AuthRequest").init(appSettings, accSettings);
// now send to one login
location ( accSettings.getIdp_sso_target_url() & "?SAMLRequest=" & authReq.getRidOfCRLF(urlEncoder.encode(authReq.getRequest(authReq.base64),"UTF-8")), false);
}
catch(Any e){
writeDump(e);
}
</cfscript>
Below is the format of auth request URL ,
https://app.onelogin.com/saml/signon/[issuerId]?SAMLRequest=[SamlRequest].
I am not providing the actual URL here since I am not sure whether someone can tamper it or not. But please do let us know if it is really required to solve this issue.
Below is the screenshot of the SAML Login Page , from here I am clicking on the button and send auth request to OneLogin.
Also, In the index.cfm , form action attribute is "/post/". Since it was throwing an error I had to replace it with "/coldfusion-onelogin/post.cfm". Here coldfusion-onelogin is a folder under wwwroot. Any settings in ColdFusion to be modified so that it will not throw any error if we keep the form action attribute as "/post/" ?.
Hmmm. The consumer URL validator is supposed to be a regex expression, and I'm not sure how it's going to handle a literal HTTP value (since it'll try to evaluate it as regex)
So try changing URL validator to be something dumb like *. (match everything)
That should hopefully clear the error until you can sort out what you want the validation to be in production.
You need to first logout from the OneLogin Admin Panel
https://app.onelogin.com/logout
To successfully test the demo app.
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 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. :)
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.
I am using Java Scribe + Spring MVC to access Facebook authentication API.
However, the URL with the access token I am getting back from Facebook is in this format:
/facebookCallback#access_token=[long chunk]&expires_in=5028
As you can see, the access_token is preceded by a #, which disallows me from obtaining the access_code as a normal parameter.
Is there any reason why Facebook is appending the # instead of a ?
var hash = document.location.hash;
I think you mean Javascript , and not Java Scribe ?
you are probably using the callback parameter which is designed for the JS library. Make sure you are not sending an incorrect parameter for "type".
Turns out that it probably was caused by my school network. I tried the exact same code both in school and at home and got different results (school - error, home - correct).
The problem solved by itself the next day in school so I won't be able to find out exactly why. Thanks to those who helped.