Allauth/facebook won't send/accept https - facebook

I've created an app and deployed it live on digitalocean and enabled HTTPS with certbot, when I want to login with facebook:
I got this error:
and the redirect URL:
is not HTTPS:
My code:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'social_django',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
]
SOCIALACCOUNT_PROVIDERS = {
'facebook': {
'METHOD': 'oauth2',
'SCOPE': ['email', 'public_profile'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'INIT_PARAMS': {'cookie': True},
'FIELDS': [
'id',
'email',
'name',
'first_name',
'last_name',
'verified',
'locale',
'timezone',
'link',
'gender',
'updated_time',
],
'EXCHANGE_TOKEN': True,
'LOCALE_FUNC': 'path.to.callable',
'VERIFIED_EMAIL': False,
'VERSION': 'v2.12',
}
}
SOCIAL_AUTH_REDIRECT_IS_HTTPS = True
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
# 'social_core.backends.facebook.FacebookOAuth2',
'allauth.account.auth_backends.AuthenticationBackend',
)
login btn
{% load socialaccount %}
Facebook OAuth2

Try adding the following to your settings:
ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https'
(see this issue on the allauth github https://github.com/pennersr/django-allauth/issues/1994)

Related

Django. Trouble logging in to facebook "rediredt failed because..."

I've been stuck in this issue for two days now and nothing. I successfully setup Google sign in and it works. Every time I try with facebook, I get the following error:
SOCIALACCOUNT_PROVIDERS = {
'google': {
'SCOPE': [
'profile',
'email',
],
'AUTH_PARAMS': {
'access_type': 'online',
}
}
}
\
{
'facebook': {
'METHOD': 'oauth2',
# 'SDK_URL': '//connect.facebook.net/{locale}/sdk.js',
'SCOPE': ['email', 'public_profile'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'INIT_PARAMS': {'cookie': True},
'FIELDS': [
'id',
"email"
'first_name',
'last_name',
'middle_name',
'name',
'name_format',
'picture',
'short_name'
],
'EXCHANGE_TOKEN': True,
'LOCALE_FUNC': 'path.to.callable',
'VERIFIED_EMAIL': False,
'VERSION': 'v13.0',
'GRAPH_API_URL': 'https://graph.facebook.com/v13.0',
}
}
ACCOUNT_DEFAULT_HTTP_PROTOCOL="https"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_AUTHENTICATION_METHOD = 'email'
Client ID and secret has been added in admin. If i remove the http method allowed, I get a different error mentioning "You can't get an access token or login to this app from an insecure page. Try re-loading the page as https://"
Any help would be appreciated. Thanks!

How to connect to web socket with APP_ID, APP_KEY and APP_SECRET with Flutter Application

How to connect to web socket with APP_ID, APP_KEY, and APP_SECRET with Flutter Application.
I used flutter_pusher_client and laravel_echo but I got `java.security.cert.CertPathValidatorException: Trust anchor for certification path not found error.
My Code
PusherOptions pusherOptions = PusherOptions(
encrypted: true,
host: 'socket.abcd.com',
cluster: 'mt1',
port: 6001,
);
FlutterPusher flutterPusher = FlutterPusher(
'PUSHER_APP_KEY',
pusherOptions,
enableLogging: true,
);
Echo echo = Echo({
'broadcaster': 'pusher',
'client': flutterPusher,
'wssHost': 'socket.abcd.com',
'wssPort': 6001,
'disableStats': true,
'forceTLS': true,
'autoConnect': true,
'enabledTransports': ['ws', 'wss'],
});
flutterPusher.connect(
onConnectionStateChange:
(FPC.ConnectionStateChange connectionStateChange) {
print(
'PUSHER CONNECTION STATE CHANGE C: ${connectionStateChange.previousState} -> ${connectionStateChange.currentState}',
);
},
onError: (FPC.ConnectionError connectionError) {
print(
'PUSHER CONNECTION ERROR C: ${connectionError.code} ${connectionError.exception} ${connectionError.message}');
},
);
echo.join('chat')
..here((user) => print('ECHO USER: user'))
..listen('NewMessage', (event) {
print('ECHO MESSAGE: $event');
});

I cannot navigate to the dashboard page after logging in keycloak in angular

I get the following error
I added the codes as follows. Keycloak login screen appears. Cannot be redirect after login.
const keycloak_config = config.keycloak;
this.keycloakAuth = Keycloak(keycloak_config);
this.keycloakAuth.redirectUri = environment.baseUrl + '/dashboard' ;
this.keycloakAuth.init({onLoad: 'login-required',
checkLoginIframe: false})
.success(() => {
resolve();
})
.error(() => {
reject();
});
One of the information in the environment file;
baseUrl: 'http://localhost:4200'
code block in app-routing.module.ts. I done useHash : false. Because if useHash : true, page is not open. I get error so;
Error: Cannot match any routes. URL Segment: 'state' Error: Cannot match any routes. URL Segment: 'state' at Anonymous function (http://localhost:4200/vendor.js:82718:17) at CatchSubscriber.prototype.error
const routes: Routes = [
{
path: '',
component: ContentLayoutComponent,
children: CONTENT_ROUTES,
canActivate: [AuthGuard]
},
{
path: 'login',
component: AuthLayoutComponent
}
];
#NgModule({
imports: [RouterModule.forRoot(routes, {useHash: false, scrollPositionRestoration: 'enabled'})],
exports: [RouterModule]
})
export class AppRoutingModule { }

Unable to Validate Field in Shopware Backend Form

I am trying to validate a field in my ExtJs file by sending a hit to my controller.. all works fine and I get the result back.. but the problem is that I am unable to get the me.article in the code as it shows undefined so my logic in the controller does not return the result as expected.
Any help would be highly appreciated.
Note: this only happens for Shopware v.5.4.6. It works fine for Shopware 5.2.
Shopware.apps.Article.view.detail.Base.prototype.createLeftElements = function() {
var me =this, articleId = null, additionalText = null;
console.log('article', me.article);
if (me.article instanceof Ext.data.Model && me.article.getMainDetail().first() instanceof Ext.data.Model) {
articleId = me.article.getMainDetail().first().get('id');
additionalText = me.article.getMainDetail().first().get('additionalText');
}
me.nameField = Ext.create('Ext.form.field.Text', {
name: 'name',
dataIndex: 'name',
fieldLabel: me.snippets.name,
allowBlank: false,
enableKeyEvents:true,
checkChangeBuffer:700,
labelWidth: 155,
anchor: '100%',
vtype:'remote',
validationUrl: '{url controller="MyController" action="check"}',
validationRequestParam: articleId,
validationErrorMsg: '{s name=detail/base/number_validation}Validation Message.{/s}'
});
// .. some code here which is irrelevant
return [
me.supplierCombo,
me.nameField,
me.mainDetailAdditionalText,
me.numberField,
{
xtype: 'checkbox',
name: 'active',
fieldLabel: me.snippets.active,
inputValue: true,
uncheckedValue:false
},
{
xtype: 'checkbox',
name: 'isConfigurator',
fieldLabel: me.snippets.configurator.fieldLabel,
inputValue: true,
uncheckedValue:false
}
];
};
I am not that deep into ExtJS, but perhaps the CSRF-protection causes this problem? Perhaps you need to whitelist your controller.
https://developers.shopware.com/developers-guide/csrf-protection/#addition-to-backend-token-validation

Facebook Feeds Popup Dialog Does Not Close

Using the FB.ui to publish a feed with parameter display:popup. When a user selects the "Cancel" or after "Share", the web site specified in the 'redirect_uri' parameter is displayed within the popup. The Facebook documentation states that the popup dialog should be dismissed when the buttons are cancelled.
Here is my code. What am I doing wrong?
<script src='http://connect.facebook.net/en_US/all.js'></script>
<script>
window.fbAsyncInit = function () {
FB.init({
appId: my APP ID, status: true, cookie: true,
xfbml: false, channelUrl: 'MY URL/fb-channel.html'
});
};
function fbShare(title, fbSiteUrl, fbThumbnailUrl, fbSiteDescription) {
var publish = {
method: 'feed',
name: title,
caption: 'MY CAPTION',
description: fbSiteDescription,
picture: fbThumbnailUrl,
link: fbSiteUrl,
redirect_uri: 'MY WEB SITE URL',
actions: [
{ name: 'MY WEB SITE Name', link: 'MY WEB SITE URL' }
],
display: 'popup'
};
function callback(response) {
}
FB.ui(publish, callback);
}
</script>