Invoking Facebook OAuth Dailog for FB 2.4 - java

Can anybody help me to invoke Facebook OAuth Dailog for FB 2.4? I tried
http://www.facebook.com/dialog/oauth/?
client_id=APP_ID
&redirect_uri=REDIRECT_URL
&state=RANDOM_NUMBER_PREVENT_CSRF
&scope=email
&response_type=code
But I got error
Given URL is not allowed by the Application configuration: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains
When I check the saml trace it seems I'm not getting a response from FB for the above request. Did I miss anything? Please advice me on this. Thanks

Related

URL blocked error in Facebook OAuth

I am implementing Facebook OAuth on my localhost where I made following configuration :
1) Setting(Basic) :
Domain : localhost
Site URL : http://localhost:9090/Facebook_Login/fbhome
Where I have changed the tomcat port to 9090 & "fbhome" is servlet which displays some information like name, gender, email after successful implementation
2) In Facebook Login section :
Valid OAuth redirect url :http://localhost:8080/Facebook_Login/fbhome
But I encountered 2 errors as mentioned below :
The requested URL /Facebook_Login/fbhome was not found on this server.
URL Blocked: This redirect failed because the redirect URI is not
whitelisted in the app’s Client OAuth Settings. Make sure Client and Web OAuth Login are on and add all your app domains as Valid OAuth Redirect URIs.
Please can anyone correct me if I have done any mistake in my configuration. It would be nice if I got proper solution. Because I googled a lot but couldn't find exact solution for it.
first you need to register to your application with call back URL, then you will get the appId and SecretId.Use those Id's and call FB OAuth url with you callbackURL

Facebook application issue with callbackurl?

In facebook application i define
Deauthorize Callback URL - http://www.domainname.com/3c/login/fblogin.xhtml
Valid OAuth redirect URIs - http://www.domainname.com/3c/login/fblogin.xhtml
-Site URL - http://www.domainname.com
now if someone access website like
http://domainname.com/3c
i am getting exception
Warning
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
Any one know how to resolve this issue
domainname.com is NOT www.domainname.com
If you have configured www.domainname.com as site URL then domainname.com is not allowed. If you do it the other way round it should work.

Google Oauth2 authentication returns "Required parameter is missing: grant_type"

I am trying to get the refresh token from Google in order to access Google drive. So Far I have managed to create a page in google app engine which redirects me to authentication page and I am able to get the code. The url address for getting there is
Window.Location.assign("https://accounts.google.com/o/oauth2/auth?scope=profile&redirect_uri=http://127.0.0.1:8888/oauth2manager/redirect&response_type=code&client_id=1058171155388-hg2akr2idan7c2kvdam9b89vptcjai8i.apps.googleusercontent.com");
I then get redirected to the /oauth2manager/redirect servlet and get the code inside the doPost method
String code = request.getParameter("code");
My problem is that I cannot proceed as I constantly get the above error "Required parameter is missing: grant_type" I have tried restclient wiztools, RestEasy firefox extension even curl.
here is my Curl script
#!/bin/bash
$code= "4/E7i1aKu4C-Pf23-8hY4Y8OBe9IBZ.wtKglnd8-CMdOl05ti8ZT3aNPWw7igI";
curl -v --data "code="+$code+"&client_id=1058171155388-hg2akr2idan7c2kvdam9b89vptcjai8i#developer.gserviceaccount.com&client_secret=JHXTAT4UWwsNaMgm******&redirect_uri= http://127.0.0.1:8888/oauth2manager/redirect&grant_type=authorization_code" https://accounts.google.com/o/oauth2/token
How can this be solved? I am a total newbie at this.
I think your mixing Oauth types. The code you are using is for normal Oauth2. But your clientid is for a service account.
Normal Oauth2 will ask a user if they want to allow your access to their data. A service account is for allowing others access to the application's data, there is no permission request with a service account.
Link to the documentation for service accounts. Service account

redirection of URL to new URL with 301 redirect not working in google app engine

How can I prevent a user from accessing my app at myproject.appspot.com and force them to access it at myproject.com? I already have myproject.com working, but I don't want users to be able to access the myproject.appspot.com domain. I'm using Java Servlet/ServletFilter with 301 redirection.
Please guide me.
Check the HTTP referrer header and act correspondingly.
If it's on the right domain, serve normally, if not, redriect.

Facebook Login redirects to localhost

I'm working on a website, which uses the Facebook Login with Spring Social. Currently I playing around with the example for version 3.
On localhost this works as intended. Online however, I get the error message that the redirect URI is invalid. The Site URL in the Facebook app is defined as http://subdomain.domain.net/myapp/. The redirect_uri Facebook sends is http://localhost:8080/myapp/signin (taken from the URL error page parameter). This is the configuration I first used.
I already tried to create a new Facebook app, in case Facebook didn't update the configuration properly. Also I tried to add to the Spring Social ConnectController the application URL. Every time I get the same error.
Turns out I made a simple configuration mistake. I thought it was sufficient to configure the ConnectController, but I missed the ProviderSignInController. Like here in the documentation

Categories