Spring social SignIn with Facebook not working - facebook

I work on an application and i want to add ProviderSignIn features. I place a button on my web page so people could connect ( signin) to my application using facebook. As documentation says (http://docs.spring.io/spring-social/docs/1.0.3.RELEASE/reference/html/signin.html), the oAuth dance :
1. POST is made to signin/facebook work(seen in firebug)
2. GET is made to signin/facebook?code="somecode" work(seen in firebug)
3. GET is made to signin but this just displays my view signin.
The documentation says :
If any error occurs while fetching the access token or while fetching the user's profile data, ProviderSignInController will redirect to the application's sign in URL. The request to the sign in URL will have an "error" query parameter set to "provider" to indicate an error occurred while communicating with the provider. The default sign in URL is "/signin" (relative to the application root), but can be customized by setting the signInUrl property.
At step 3, my url is signin#= and not signin with error query parameter.
I don't understand why i am not getting error in query parameter ?

Just create your own controller which extends ConnectController and implements it's methods. It worked for me.

Related

How to track URL in flutter with website platform

I want to do oAuth2 verification in my website login page and after that I want to get token from url with same page but issue is i can`t able to get URL.
below URL is OAuth2 url using this url I am doing authentication steps with website using flutter.
1st this website will open in browser after that login page will open and after login i will get access_token. But i facing difficulties how i can get access_code with html.window.location function.
I have tried with this code
WidgetsBinding.instance!.addPostFrameCallback((_) {
html.window.location.assign(
'https://example/connect/authorize?response_type=token&client_id=$clientId&redirect_uri=https://example.app/silentRenew&scope=getinfo');
});
Anyone have better solution than please give suggestion.
Pinal! I did an oAuth2 flux recently consuming Gitlab API. I suggest you to use
the oauth2 plugin: oauth2. You just need to have the authorization endpoint, access token endpoint and the redirect url.
After this, you just need to call 3 methods.
Getting your AuthorizationCodeGrant.
var grant = oauth2.AuthorizationCodeGrant(identifier, authorizationEndpoint, tokenEndpoint,secret: secret)
Get Authorization Url.
var authorizationUrl = grant.getAuthorizationUrl(redirectUrl);
Get the returned Code.
await grant.handleAuthorizationResponse(responseUrl.queryParameters);
The method return your code automatically.
In my case, I used a webview instead opening the browser to listen the redirected url's. WebView
You just have to pass the authorizationUrl as the initial page flag inside webview, and listen to the url's with onPageStarted flag. So what you wanna do is: when the redirectUrl ,which gives you the code to authorize your access token, is accessed you call the method 3, only in this moment. I hope this help you, let me know if you struggle with something.

Keycloak - direct user link registration

I have set up a web application with Keycloak in my local machine. Since Im using Keycloak as SSO implementation, I want in my web app that whenever SIGNUP button is click, user is directed into the registration page, and not going through the LOGIN page.
This is the example URL directed to the registration form, however, it contains a tab_id that is generated randomly like a session id.
https://site.test/auth/realms/custom/login-actions/authenticate?client_id=test&tab_id=qIdW92Bvwmk
I read about this link
Yes, as long as you use the "registrations" instead of "auth" in the
end of login ( AuthorizationEndpoint ) URL
But my endpoint in https://site.test/auth/realms/custom/.well-known/openid-configuration cannot be modified.
You can change the button link to this format -
http://<domain.com>/auth/realms/<realm-name>/protocol/openid-connect/registrations?client_id=<client_id>&response_type=code&scope=openid email&redirect_uri=http://<domain.com>/<redirect-path>&kc_locale=<two-digit-lang-code>
The registration page is exposed via an openid-connect endpoint, accessible in the same way as the standard auth screen. To construct the correct URL you can simply replace openid-connect/auth in the URL with openid-connect/registrations from the .well-known auth endpoint.
authEndpoint.replace("openid-connect/auth","openid-connect/registrations");
Using this endpoint the user will be directed to the registration screen instead of the login screen.
It is not documented or exposed via .well-known/openid-configuration, but you can see it in the source code:
public static UriBuilder registrationsUrl(UriBuilder baseUriBuilder) {
UriBuilder uriBuilder = tokenServiceBaseUrl(baseUriBuilder);
return uriBuilder.path(OIDCLoginProtocolService.class, "registrations");
}
For Keycloak 17 this worked for me:
http://<mykeycloakdomain.com>/realms//protocol/openid-connect/registrations?client_id=<myclient_id>&response_type=code&scope=openid+email&redirect_uri=https%3A%2F%2Fmywebsiteurl.com&kc_locale=

How to simply use facebook login for my app without using the SDKs?

Is there a simple flow (hello world) for a user to login using facebook?
Found documentation on Manually Build a Login Flow, but is too full of text and details that I don't see the main flow.
Based on Manually Build a Login Flow (showing only the minimal data needed to make it work):
Create a facebook app.
Simulate the user clicking on the following authentication URL to allow the app to access the user's data: https://www.facebook.com/v2.8/dialog/oauth?client_id=<app id>&redirect_uri=http://localhost/
Click ok/accept/whatever to authorize access.
You get redirected by facebook to a URL of the following: http://localhost/?code=<code>
Take the code and invoke the following: curl 'https://graph.facebook.com/v2.8/oauth/access_token?client_id=<app id>&redirect_uri=http://localhost&client_secret=<app secret>&code=<code>'
You get a result like the following: {"access_token":"<access token>","token_type":"bearer","expires_in":5183924}
You can then use the access token to call API related to the user that gave the permissions to your app. Example: curl 'https://graph.facebook.com/v2.8/me?access_token=<access token>'
Example response: {"name":"Alik Elzin","id":"<app related user id>"}
* Remember to add http://localhost/ to the app's Valid OAuth redirect URIs - under app settings.
Have you checked out this documentation from Facebook? It's pretty short to read through: https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow

The page cannot be displayed error Facebook

This is the FB Url I am trying to access.
https://graph.facebook.com/oauth/authorize?client_id=694aa71aed60fb9d79aae04b81ff27c8&redirect_uri=http://localhost/TestConnect/Facebook.aspx&scope=email,user_about_me,user_interests,user_likes,user_location,user_notes,user_education_hi
It says
The page cannot be displayed
There are too many people accessing the Web site at this time.
It was working fine until last night
Even when I type it in the browser, it has no response. All it shows me is a green progress bar even after 20min
What should I do?
Thanks
SC
Here is your URL :
https://graph.facebook.com/oauth/authorize
?client_id=694aa71aed60fb9d79aae04b81ff27c8
&redirect_uri=http://localhost/TestConnect/Facebook.aspx
&scope=email,user_about_me,user_interests,user_likes,user_location,user_notes,user_education_hi
When changing redirect_uri to http://localhost it works fine for me. So I guess it is your page http://localhost/TestConnect/Facebook.aspx that does not works fine.
The redirect_uri will be called with GET parameters, be sure to handle them correctly :
If the user allows your app, he will be redirected to :
http://localhost/TestConnect/Facebook.aspx?code=...
and you will need to get a ask an access token to facebook with that code (the code parameter) by calling :
https://graph.facebook.com/oauth/access_token
?client_id=YOUR_APP_ID
&redirect_uri=YOUR_URL
&client_secret=YOUR_APP_SECRET
&code=THE_CODE_FROM_ABOVE
If the user doesn't allow your app, he will be redirected to :
http://localhost/TestConnect/Facebook.aspx
?error_reason=user_denied
&error=access_denied
&error_description=The+user+denied+your+request.
so you can detect that error by testing the get parameter error.
Hope that helps !

Facebook cannot redirect the next parameter

When I authenticate the user, after authentication it does not redirect the next parameter. Instead it redirect the user to the "Canvas Callback URL". If I dont give the convas callback url. then it gives the error
An error occurred with experiement. Please try again later.
API Error Code: 100
API Error Description: Invalid parameter
Error Message: next is not owned by the application.
on the other hand if the user cannot allow my app then it redirect the next parameter.
My url for authentication is:
https://login.facebook.com/login.php?api_key=**KEY**&v=1.0&popup=1&next=**NEXT**&
next_cancel=**NEXT_CANCEL**&skipcookie=1
I try to this on localhost.
in any one have idea about this?
Try using this url instead to get permissions:
$facebook->redirect('https://graph.facebook.com/oauth/authorize?
client_id=[YOUR APP ID]&
redirect_uri=[YOUR APP URL]&
scope=publish_stream, offline_access');
Replace [YOUR APP ID] with application id that you can see from application settings where you created the site in Facebook Developers section. Also replace the [YOUR APP URL] with your app url.
And $facebook variables is the one you get by initiating the facebook client that is:
$facebook = new Facebook($appapikey, $appsecret);
Yes it always redirects to canvas url instead of app url. You just need to create your own server side redirect that would redirect user back to app url.
You can separate regular app calls from the one after authorization that requires manual redirect by looking at request parameters. After authorization you would get some unique params like auth_token that are not present in a regular request. If those params are present - it means that it is authorization redirect and you need to send user back to app url.