eBay oauth token flow on small screen i.e. smartphone - oauth

I've been struggling for couple of days with eBay token authentication on smartphones. I am able to register customer tokens on desktop systems, tablets and hires smartphones. On the android app there is a intent listener to get the reply and register the token within the app.
But on some devices, the following message occurs within registration flow trough ebay:
This can not be done on a small screen. Please try again with a desktop computer.
eBay customer support told me, that it is not possible to use the registration on apps. But i don't understand this, because the registration window for the token registration flow is matching even on small devices!
Any idea to solve this? Eventually to simulate a higher resolution / meta information for the web-view so the message wouldn't generated from the eBay server?
Thank you very much for any idea.

I had to zoom out the browser window
https://stackoverflow.com/a/4322209/1849478
also needed to set the UserAgent of the Webview like this:
String agent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/20100101 Firefox/4.1";
mWebView.getSettings().setUserAgentString(agent);

Try to set the browser size with javascript.
<html>
<head>
<script>
window.alert("Window resolution before overwrite is " + window.screen.availWidth + " x " + window.screen.availHeight);
Object.defineProperty(window.screen, "availWidth", { get: function(){return 0; }});
Object.defineProperty(window.screen, "availHeight", { get: function(){return 0; }});
</script>
</head>
<body>
<script>
window.alert("Window resolution after overwrite is " + window.screen.availWidth + " x " + window.screen.availHeight);
</script>
</body>
</html>
Here is another way

Related

Access localhost via Microsoft Edge extension background page

Recently we migrated a Chrome extension to Microsoft Edge. For Edge hasn't implemented native messaging, so we want to communicate with native app by websocket via Edge extension background page.
After testing, we found that, in the background page websocket can access external host successfully, but localhost, even though access '127.0.0.1' failed.
And we try to access localhost in the web page, it did!
Edge browser info:
userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64; ServiceUI 8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393"
We have checked "Allow localhost loopback (this might put your device at risk)" from about:flags.
Does Edge extension background page support access localhost? If it does, how can we achieve it? If not, could anyone help?
We run the WebSocket server as this example: https://blog.idrsolutions.com/2013/12/websockets-an-introduction/.
The extension can be downloaded from: https://github.com/chhxia/Edge-Extension.
The code of edge extension background js:
var ws;
function openSocket(){
var socket, path;
// path = 'wss://echo.websocket.org'; // successfully access this path.
path = 'ws://localhost:8080/EchoChamber/echo';
console.log( '===> Tested path :: ', path );
try {
ws = new WebSocket( path );
}
catch ( e ) {
console.error( '===> WebSocket creation error :: ', e );
}
ws.onopen = function(){
alert('open...');
ws.send('text');
}
ws.onmessage = function(e){
alert("receive: " + e.data);
}
ws.onclose = function(e){
ws = undefined;
alert('close...' + e);
}
}
(function(){
openSocket();
browser.browserAction.onClicked.addListener(function(tab) {
if(ws === undefined){
openSocket();
}else if(ws && ws.readyState === WebSocket.OPEN){
alert('send');
ws.send('text');
}else{
alert('websocket is closed.');
}
});
})();
To save you a few clicks: IE, Chrome, and Firefox allow it, Edge doesn't. Microsoft says that accessing localhost in Edge extensions is blocked by design:
"We are working on Native Messaging for the next release and using
native messaging is the right way to solve this scenario. Localhost
access is not enabled from extension background page is by design."
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8984919/
... and native messaging for Edge requires an UWP host:
"At a high level, Microsoft Edge extensions use the same APIs for
native messaging as Chrome and Firefox extensions. However, the native
messaging host will need to be implemented using the Universal Windows
Platform."
https://learn.microsoft.com/en-us/microsoft-edge/extensions/guides/native-messaging
I ran into this issue while developing my own extension for Edge. I had also checked the "Allow loopback..." setting in about:flags and so I was very confused and frustrated. Having your extension be able reach localhost while developing seems like a reasonable thing to want... right?
It turns out that you can actually access localhost from an Edge extension. You just have to ensure that you add Edge to the loopback exempt list by running CheckNetIsolation LoopbackExempt -a -n="Microsoft.MicrosoftEdge_8wekyb3d8bbwe" in a Powershell prompt (running in Administrator mode).
To undo that, just run CheckNetIsolation LoopbackExempt -d -n="Microsoft.MicrosoftEdge_8wekyb3d8bbwe".
Edge issue regarding Edge extensions and localhost requests: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/13966307/.
Access localhost via Microsoft Edge extension background page
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8984919/

Cannot login to yammer using yam.connect.logonButton in IE11

Trying to login using yam.connect.loginButton, works fine on firefox and chrome but not on IE (I am using IE11). The response has an auth but no user object. Or sometimes the popup window doesn't close and the callback is never called. Code I used is below:
<html>
<head>
<script id="yammer-js-include" data-app-id="APP-CLIENT-ID-GOES-HERE" src="https://assets.yammer.com/assets/platform_js_sdk.js"></script>
</head>
<body>
<span id="yammer-login"></span>
<script>
yam.connect.loginButton('#yammer-login',
function (response) {
console.dir(response);
document.getElementById('yammer-login').innerHTML = 'user ' + (typeof response.user !== 'undefined' ? 'exists in response' : 'is missing!');
}
);
</script>
</body>
</html>
You mention that was the code you used, but did you replace the data-app-id with the one provided from your app on https://yammer.com/client_applications ?
Assuming yes, a lot of people run in to problems with IE and not having Yammer urls added to Trusted Sites in IE. If you can add more logs from your console output that it would help.
You can read more about what to include in your Trusted Sites here:
http://developer.yammer.com/connect/#IETrustedSites
When I add the host of where my app was running also in the Trusted Sites, it worked.
http://kendomen.wordpress.com/2014/11/06/yammer-authentication-with-javascript-and-yammer-sdk/

Submit a form embedded in an iFrame does not work in iOS 7

In a website with mydomain.tld, an iFrame containing a form that is hosted on otherdomain.tld is embedded. Both sites are non-SSL running on port 80.
Now, this form won't submit on iPhone 5 running on iOS 7. I can reproduce it in the iOS-Simulator when choosing "iPhone Retina (4-inch 64-bit)" (doesn't happen with "4-inch" only).
The submit event is triggered (at least if I catch it via JavaScript) but no request is made according to the developer tools.
If I open the iFrame source directly, the form will submit.
I had a similar problem with Internet Explorer and learned about P3P and could solve the problems sending a special P3P header:
P3P: CP="IDC DSP COR CURa ADMa OUR IND PHY ONL COM STA"
But for the problem mentioned with Safari this doesn't seem to be the problem.
Are there any known restrictions regarding Safari and forms in iFrames?
As I've found out, the problem was related to using cookies in iFrames which triggered the Spamshield of the form in the iFrame to block the form submission.
Since it's an opt-in form, I deactivated the Spamshield, but I've found a solution (which I didn't test) that should make cookies work by a submit to a hidden form that is triggered on loading the iFrame content.
<script> window.setTimeout(function() {
if (document.cookie.indexOf('test_cookie=1') < 0) {
var
name = 'test_cookie',
div = document.getElementById(name),
iframe = document.createElement('iframe'),
form = document.createElement('form');
iframe.name = name;
iframe.src = 'javascript:false';
div.appendChild(iframe);
form.action = location.toString();
form.method = 'POST';
form.target = name;
div.appendChild(form);
form.submit();
} }, 10); </script>
Source: https://gist.github.com/daaku/586182
IOS devices change numbers to anchor links with href="tel:xxxxx" and mess up json data
http://xatzis.com/2014/03/29/submitting-forms-iframes-ios-devices/

Building Twitter profile image url with Twitter user id

Is there any way of building a profile image url with user id or screen name? I store user ids in database but i don't want to store profile image url.
edit:
I don't want to make a api call too. I want to put user_id inside a url like
<img src="https://twitter.com/users/profile_pic?user_id=123"> Is there a url to do this?
With API 1.1 you can achieve this using these URLs:
https://twitter.com/[screen_name]/profile_image?size=mini
https://twitter.com/[screen_name]/profile_image?size=normal
https://twitter.com/[screen_name]/profile_image?size=bigger
https://twitter.com/[screen_name]/profile_image?size=original
Official twitter documentation Profile Images and Banners
Example
https://twitter.com/TwitterEng/profile_image?size=original
will redirect to
https://pbs.twimg.com/profile_images/875168599299637248/84CkAq6s.jpg
As of June 2020, both the accepted answer and avatars.io no longer work. Here are two alternatives:
unavatar.io
(formerly unavatar.now.sh)
Unavatar can get pictures from quite a few different places including Twitter. Replace [screen_name] in the URL below with the Twitter username you want.
<img src="https://unavatar.io/twitter/[screen_name]" />
For example:
<img src="https://unavatar.io/twitter/jack" width="100" height"100" />
If the demo above ever stops working, it's probably because unavatar.io is no longer available.
Unavatar is open source though, so if it does go down, you can deploy it yourself from the GitHub repo — it even has "Deploy to Vercel/Heroku" buttons. The code to fetch Twitter avatars specifically is here, so you could also use that as part of your own backend.
twivatar.glitch.me
⚠️ As of July 2021 this option no longer works, see the one above instead!
If you want an alternative, you can also use twivatar.glitch.me. Replace [screen_name] in the URL below with the Twitter username you want.
<img src="https://twivatar.glitch.me/[screen_name]" />
For example:
<img src="https://twivatar.glitch.me/jack" width="100" height"100" />
If the demo above ever stops working, it's probably because twivatar.glitch.me is no longer available.
By the way, I didn't build either of these services, they were both made by other people.
Introducing the easiest way to get a Twitter Profile Image without using the Twitter API:
Using http://avatars.io/
As #AlexB, #jfred says, it doesn't work at all on mobile devices.
And it's quite a hard way to get a redirected URL using common frameworks like PHP or JavaScript in your single page.
Simply call http://avatars.io/twitter/ruucm at your image tag, like
<img src="https://avatars.io/twitter/ruucm" alt="twt_profile" border="0" width="259"/>
I've tested it with Angular 2+ and it works without any problem.
As of February 20, 2020 it would appear this is impossible. Using the API seems like the only option at the moment. For more info see my question I've opened here: Twitter profile picture images now blocked on most domains
Based on the answer by #Cristiana214
The following PHP snippet can be used to make the https://twitter.com/[screen_name]/profile_image?size=normal trick work on mobile.
Due to twitters redirect to the mobile version of the site links such as https://twitter.com/[screen_name]/profile_image?size=normal get broken on mobile devices
So the script gets the redirect response (to the user avatar) extracts the address then redirects the page itself
if (!isset($_GET['id'])) $_GET['id'] = 'twitter';
$urlget = curl_init();
curl_setopt($urlget, CURLOPT_URL, 'https://twitter.com/' . $_GET['id'] . '/profile_image?size=normal');
curl_setopt($urlget, CURLOPT_HEADER, true);
curl_setopt($urlget, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($urlget);
preg_match_all("/location: (.*)/", $res, $found);
header('Location: ' . $found[1][0]);
So this could be accesses as twitteravatar.php?id=twitter which (at time of writing) reloads to https://pbs.twimg.com/profile_images/767879603977191425/29zfZY6I_normal.jpg
Not pretty but works.
You can get it using the users/show method of the Twitter API -- it does exactly what you described. You give it a the ID or the screen name, and it returns a bunch of data, including profile_image_url.
I found such a solution with C#:
public string Text_toTextFinder(string text, string Fromhere, string Here)
{
int start = text.IndexOf(Fromhere) + Fromhere.Length;
int finish = text.IndexOf(Here, start);
return text.Substring(start, finish - start);
}
string getPhotoURL(string UserName, string size ="x96")
{
using (WebClient client = new WebClient())
{
client.Headers[HttpRequestHeader.UserAgent] = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
string htmlCode = client.DownloadString("https://twitter.com/" + UserName);
return Text_toTextFinder(Text_toTextFinder(htmlCode, "<td class=\"avatar\">", "</td>"), "src=\"", "\"").Replace("normal",size);
}
}
For use:
MessageBox.Show(getPhotoURL("screen_name")); //size = 96x96
MessageBox.Show(getPhotoURL("screen_name","normal"));
MessageBox.Show(getPhotoURL("screen_name","200x200"));
MessageBox.Show(getPhotoURL("screen_name","400x400"));
There is no way to do that. In fact Twitter doesn't provide a url to do that like facebook does ( https://graph.facebook.com//?fields=picture)
The issue is report but the status is: 'WontFix', take a look:
https://code.google.com/p/twitter-api/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Stars%20Type%20Bug%20Status%20Summary%20Opened%20Modified%20Component&groupby=&sort=&id=242#makechanges
Well I'm using a tricky way via PHP Dom Parser
include('simple_html_dom.php');
$html = file_get_html('http://twitter.com/mnckry');
$img = array();
foreach($html->find('img.size73') as $e)
$img[] = $e->src;
foreach($html->find('.profile-header-inner') as $e)
$img[] = str_replace("')", "", str_replace("url('", "", $e->{'data-background-image'}));
echo $img[0];//Avatar
echo "<br>";
echo end($img);//ProfileBG
This will give you something like this;
https://pbs.twimg.com/profile_images/378800000487958092/e04a191de329fcf8d000ca03073ad594_bigger.png
to get 2 other size; for big version remove, "_bigger" for smaller version replace "_bigger" with "_normal"
With version 1.1, use
http://a0.twimg.com/profile_images/XXXXX/afpecvf41m8f0juql78p_normal.png
where XXXXX is the User Id

Service Unavailable 503 error, request from Google App Engine app

I have been using YouTube Data API from Google App Engine app for 5 months, without getting Service Unavailable, 503 error response. But today, I got this:
YouTubeError: {
'status': 503,
'body': '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\n<html>\n<head><meta http-equiv="content-type" content="text/html; charset=utf-8"><title>http://gdata.youtube.com/action/GetUploadToken</title></head>\n<body style="font-family: arial, sans-serif; background-color: #fff; color: #000; padding:20px; font-size:18px;" onload="e=document.getElementById(\'captcha\');if(e){e.focus();}">\n<div style="max-width:400px;">\n <hr noshade size="1" style="color:#ccc; background-color:#ccc;"><br>\n \n \n <div style="font-size:13px;">\n Our systems have detected unusual traffic from your computer network. Please try your request again later. Why did this happen?<br><br>\n <div id="infoDiv0" style="display:none; background-color:#eee; padding:10px; margin:0 0 15px 0; line-height:1.4em;">\n This page appears when Google automatically detects requests coming from your computer network which appear to be in violation of the Terms of Service. The block will expire shortly after those requests stop.<br><br>This traffic may have been sent by malicious software, a browser plug-in, or a script that sends automated requests. If you share your network connection, ask your administrator for help — a different computer using the same IP address may be responsible. Learn more<br><br>Sometimes you may see this page if you are using advanced terms that robots are known to use, or sending requests very quickly.\n </div><br>\n \n IP address: 74.125.19.24<br>Time: 2012-10-09T17:48:20Z<br>URL: http://gdata.youtube.com/action/GetUploadToken<br>\n </div>\n</div>\n</body>\n</html>\n',
'reason': 'Service Unavailable'
}
I am using YouTube for uploading videos from users, and also for displaying existing videos (users only input the videos URL).
Does anybody know possible reasons why it isn't working?
I am using gdata python library.
I have yt_service property defined in my video model:
def yt_service(self):
try:
return self._yt_service
except AttributeError:
yt_service = gdata.youtube.service.YouTubeService()
yt_service.developer_key = settings.SYNCR_YT_DEVKEY
yt_service.email = settings.SYNCR_YT_EMAIL
yt_service.password = settings.SYNCR_YT_PASS
yt_service.ProgrammaticLogin()
self._yt_service = yt_service
return yt_service
Then when creating upload form, view call yt_service.GetFormUploadToken to retrieve upload token. It failed in here.

Resources