Social login in mobile device

Hi,
I have a problem on login with the plugin in mobile devices.
The site with the plugin is: http://hockeybud.dev.dmsdn.com/topoftheworld/
The implementation:
In the index page the code to call the plugin is:
<script type="text/javascript">  
	/* Replace #your_subdomain# by the subdomain of a Site in your OneAll account */    
	var oneall_subdomain = 'topoftheworld';
	
	/* The library is loaded asynchronously */
	var oa = document.createElement('script');
	oa.type = 'text/javascript'; oa.async = true;
	oa.src = 'http://' + oneall_subdomain + '.api.oneall.com/socialize/library.js';
	var s = document.getElementsByTagName('script')[0];
	s.parentNode.insertBefore(oa, s);

	var my_on_login_redirect = function(args) {
		jQuery.ajax({ url: "callback_handler.php?user_token="+args.connection.user_token})
			.success(function(data, textStatus, jqXHR) {
				if(data.exists){
					window.location.href = 'thanksyou.php';	
				}else{
					if ("user_token" in data.response.result.data.user){
						var user_token = data.response.result.data.user.user_token;
						$('#social_token').val(user_token);
					}
					if ("emails" in data.response.result.data.user.identities[0]){
						var email = data.response.result.data.user.identities[0].emails[0].value;
						$('#email').val(email);
					}
					if ("currentLocation" in data.response.result.data.user.identities[0]){
						var currentlocation= data.response.result.data.user.identities[0].currentLocation;
						$('#city').val(currentlocation);
					}
				}
				
			});

		return false;
	}
 /* Embeds the buttons into the container oa_social_login_container */
	var _oneall = _oneall || [];
	_oneall.push(['social_login', 'set_providers', ['facebook', 'twitter', 'instagram','google']]);
	_oneall.push(['social_login', 'set_grid_sizes', [4,1]]);
	// _oneall.push(['social_login', 'set_custom_css_uri', '//http://ec.oneoneapp.dev.dmsdn.com/test.css']);
	// _oneall.push(['social_login', 'set_callback_uri', your_callback_script]); // We'll use an ajax call instead a redirect.
	_oneall.push(['social_login', 'set_event', 'on_login_redirect', my_on_login_redirect ]);
	_oneall.push(['social_login', 'do_render_ui', 'oa_social_login_container']);
</script>
The callback_handler.php:
<?php
require('../wp-config.php' );
global $wpdb;
$exists = '{"exists":"true"}';


//Your Site Settings
$site_subdomain = 'topoftheworld';
$site_public_key = '################################';
$site_private_key = '###############################';

//API Access Domain
$site_domain = $site_subdomain.'.api.oneall.com';
$user_token = $_GET['user_token'];	
//Connection Resource
$resource_uri = '//'.$site_domain.'/users/'.$user_token.'.json';

$userexist = $wpdb->get_results( "SELECT id FROM topoftheworld_register WHERE social_token='".$_GET['user_token']."';" );
if(!empty($userexist)){
	header('Content-Type: application/json');
	echo $exists;
}else{
	//Setup connection
	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $resource_uri);
	curl_setopt($curl, CURLOPT_HEADER, 0);
	curl_setopt($curl, CURLOPT_USERPWD, $site_public_key . ":" . $site_private_key);
	curl_setopt($curl, CURLOPT_TIMEOUT, 15);
	curl_setopt($curl, CURLOPT_VERBOSE, 0);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
	curl_setopt($curl, CURLOPT_FAILONERROR, 0);

	//Send request
	$result_json = curl_exec($curl);
	curl_close($curl);
	$result = json_decode($result_json);

	header('Content-Type: application/json');

	echo $result_json;
}
The error is:
When I access to the site on my mobile device, click in the social login, access to the social network, and then show this error:
ERR_UNKNOWN_URL_SCHEME
is posible that page doesent work temporaly or permanently moving has a new address null://topoftheworld.api.oneall.com/socialize/redirect.html?provider_connection_token=##########################_=_

The error is only in mobile devices, in desktop the login works fine.

Answers

  • Hi,
    Somehow the transport part is lost. There are reports of similar behaviour on mobile.
    One turnaround would be to set the full URL in the ajax call of your login_redirect function.
    For this, you could use the args.callback_uri, which should hold the full URL to your callback.

    Hope this helps.
  • The ERR_UNKNOWN_URL_SCHEME error is commonly because of your browser issue . There's no application on your device which can handle that particular action. It is a Chromium bug . In Chrome version 40 and up, this bug has resurfaced, but only if you are manually entering the URL of the redirect page in the address bar. The issue is on the chromium issue tracker here .

  • Kuer_PolinKuer_PolinMember
    edited December 2023

    Thank you very much for this document, it helped me a lot! I will apply it to the Quick Draw website

  • You're very welcome! I'm glad the information was helpful to you. wink mod apk

Welcome!

Please sign in to your OneAll account to ask a new question or to contribute to the discussions.

Please click on the link below to connect to the forum with your OneAll account.