Oauth.io service and social network linking, unlinking? - javascript

I'm using https://oauth.io/ service and I'm a little bit unlucky with finding correct documentation on few things:
Is it possible to unauthorize one or another social network from application? In other words destroy permissions for application to use user's settings of that network.
How do I make google plus oauth work:
There is an example for facebook:
OAuth.popup('facebook', function(err, res) {
if (err) {
// do something with error
}
res.get('/me')
.done(function(data) {
alert('Hello ' + data.name)
})
})
It does work for me but I can't figure out how can I make it work with google+ API. When I change provider to google_plus I manage to get authorization token but I'm not sure how to proceed further because calling res.get('/me') doesn't work ('I suppose /me is only for facebook API'). I've tried lots of different other urls that are for google+ but it seems that because G+ doesn't support CORS request it makes request to local oauthd server like so: options.url = config.oauthd_url + '/request/' + options.oauthio.provider + options.url; network returns that no such endpoint exists.
Please if anyone know how to solve this help me.
Thank you

I just ran into this problem too, and I found a jsfiddle
res.get('/plus/v1/people/me').done(function (me) {
$('#connect').slideUp('fast')
$('#res').html(template({
data: me
})).slideDown('fast')
res.get('/plus/v1/people/me/activities/public').done(function(activities) {
$('#activities').html(activitiesTemplate({
data: activities
}))
});
})

Related

instafeed.js stopped working: The access_token provided is invalid

I am using instafeed.js like so:
var feed = new Instafeed({
get: 'user',
userId: 19191919191,
limit: 9,
accessToken: 'myaccesstokenhere',
target: 'instagram',
resolution: 'standard_resolution',
after: function() {
var el = document.getElementById('instagram');
if (el.classList)
el.classList.add('show');
else
el.className += ' ' + 'show';
}
});
but I am getting this error:
The access_token provided is invalid.
I got the access_token by https://www.instagram.com/developer I registered my application and put the Client Secret as the accessToken and I got my userID from here https://smashballoon.com/instagram-feed/find-instagram-user-id/
but its still saying The access_token provided is invalid. what am I doing wrong?
You cannot use your Client Secret in place of accessToken, as the Client Secret is used server-side as part of the OAuth process in order to get the user accessToken.
I suggest reviewing Instagram's Authentication docs here to be sure you're using the Authentication strategy that makes sense for your application.
It sounds like you're more likely to want to use their Client Side Implicit Authentication (at the bottom) to get an access token. You can even do this yourself manually to just get an accessToken for testing. Once you have the accessToken, then you can simply use that in the correct field for instafeed.js to load what you want from Instagram.
You can also just get your own accessToken by going to http://instagram.pixelunion.net/ and using the one generated there.
Seems you confused accessToken with Client Secret, check it here https://www.instagram.com/developer/authentication/
To make life easy you can try to generate one here http://instagram.pixelunion.net/

Tumblr API - can GET but not POST

I'm trying to create a page where users can log in with their tumblr account and fill out a form to post to their blog.
I'm using hello.js with the tumblr module.
I've modified the tumblr module demo and everything seems to be working in terms of logging in and authenticating. However, I'm unable to convince the API to let me use any OAUTH-restricted POST commands. GET commands, such as retrieving a user's followed blogs, work fine. But if I try something simple such as user/follow to follow a new blog, I get a "401 Not Authorized" response.
What could be causing OAUTH restricted GET commands to be working fine, but POST does not?
You can see my testing code live at http://www.jereddanielson.com/testing/tumblr/hello.js-master/demos/tumblr.html
Below is the pertinent javascript. I'm using the OAUTH proxy at https://auth-server.herokuapp.com/
function login(network){
hello( network ).login({scope: 'publish_actions, publish, post, post_actions, follow, follow_actions'}).then( function(r){
// Get followed blogs
hello(network).api({path: '/user/following', method: "get"}).then(function(p){
console.log(p);
console.log("Tried to retrieve followed blogs. Response status: " + p.meta.status + " " + p.meta.msg);
});
// Try to follow a blog
hello(network).api({path: '/user/follow', method: "post", data: {url: "daily-fractal.tumblr.com"}}).then(function(p){
console.log(p);
console.log("Tried to follow a blog. Response status: " + p.meta.status + " " + p.meta.msg);
});
}, function(e){
console.error(e);
});
}
hello.init({
'tumblr' : "bQpjOrKgIu9pWVann1HVOAoW6gOGNoSpcMXIpwjNqghUmkwvgt"
},
{
redirect_uri:'../redirect.html',
oauth_proxy: "https://auth-server.herokuapp.com/proxy"
});
Thanks.

geo_ip.js is not working

I am using "http://j.maxmind.com/app/geoip.js" for multilingual site support but this link is throwing 404 error.
Here is the error
Failed to load resource: the server responded with a status of 404 (Not Found)
www.globalenglish.com/:913 Uncaught ReferenceError: geoip_country_code is not defined
chrome-extension://gllmlkidgbagkcikijiljllpdloelocn/contentscript.js:1849 www.globalenglish.com
getuid:1 GET https://api.bizographics.com/v2/getuid?api_key=422935bcbfc445d59f10758c288c…I%252bJLufjW0EE6tV4BHMF43u8yA9qpnPTK8G7tGxJuiy5ReJz%252fscH55wHNbnsJU%253d 403 (Forbidden)
I checked the site here for new link, this link throws 401 error.
I also checked new API here but this also did not work for me. JS Link works but geoip_country_code() is undefined
How to make it work again !!!! Here is fiddle
Thanks
Unfortunately, Maxmind doesn't provide a geoip api through
http://j.maxmind.com/app/geoip.js
anymore. Although it provides another api as
http://js.maxmind.com/js/apis/geoip2/v2.1/geoip2.js
However it requires a domain registration etc. according to Maxmind's website. The link below is a clone of the old api and valid for around one year now.
http://geoapi123.appspot.com/
I've just used this for one of my projects in development stage for a very quick solution. But I strongly suggest you to update your code according to a trustworthy service again.
A working jsfiddle to show how things could play on here; which shows this chunk of code:
$.ajax( {
type: 'GET',
url: '//geoapi123.appspot.com/',
dataType: 'script',
cache: true,
success: function() {
var geo = geoip_country_code() + '|' + geoip_region_name() + '|' + geoip_city() + '|' + geoip_latitude() + '|' + geoip_longitude();
$('#results').html(geo);
}
});
UPDATE:
I realised this answer is still getting attraction. Please be aware it has been years since I wrote this one. The URL I shared does not seem to be working anymore. Also there are much better approaches to handle the problem now.
Actually, there is a message in the console you might have missed :
Users of the GeoIP2 JavaScript API must register their domains at
https://www.maxmind.com/en/javascript_domains
The loading of the library failed because a request is issued to the js.maxmind.com domain with your current hostname (fiddle.jshell.net in your case) as the referrer to ensure that the client was actually making a request from an authorized hostname.
hey guys i'm using This script but i don't know why HTTPS doesn't work when i try to redirect .. it only work With HTTPS
$.ajax({
url: "http://api.petabyet.com/geoip",
success: function(data) {
switch (data.country_code) {
case 'DE':
window.location.href = "https://google.com/de";
break;
}
}
})
</script>

How to get LinkedIn API access token without a redirect

I'm trying to use LinkedIn's API to access Universities LinkedIn pages to periodically collect how many followers they have. This seems doable, but I cant seem to generate an access token without having some weird redirect URL that has to take you to a GUI login page!
I'm using node.js for this, specifically this package: https://www.npmjs.org/package/node-linkedin
I have a API key and secret, so all I need is a access token then I'll be set to actually start using their API routes.
var Linkedin = require('node-linkedin')('KEY', 'SECRET', 'callback');
var linkedin = Linkedin.init('my_access_token'); // need a token to initialise!
Any ideas?
Edit: Here's my code so far:
var Linkedin = require('node-linkedin')('KEY', 'SECRET', './oauth/linkedin/callback');
app.get('/oauth/linkedin', function(req, res) {
// This will ask for permisssions etc and redirect to callback url.
Linkedin.auth.authorize(res, ['r_basicprofile', 'r_fullprofile', 'r_emailaddress', 'r_network', 'r_contactinfo', 'rw_nus', 'rw_groups', 'w_messages']);
});
app.get('/oauth/linkedin/callback', function(req, res) {
Linkedin.auth.getAccessToken(res, req.query.code, function(err, results) {
if ( err )
return console.error(err);
/**
* Results have something like:
* {"expires_in":5184000,"access_token":". . . ."}
*/
console.log(results);
var linkedin = Linkedin.init(result);
return res.redirect('/');
});
});
What you are trying to do is an application-only authentication, it seems linkedIn has removed this option unlike facebook and twitter. As from now it is only possible to authenticate as a user.
If you really want to skip the redirect you could use something like PhantomJS which is a headerless browser. But i strongly recommend you not to do so as LinkedIn requires a user to authenticate in their license agreement. I don't know if it is legal but you could provide yourself an end-point which you use to generate the authentication_code and access_token and then save it to a database (60 days valid by default).

CocoonJS and Facebook extended permissions

First of all, I'm aware there are plenty of questions and answers relating this topic. However, none of them works for me (maybe because they are old and the methods have become outdated, I don't know)... Let me briefly explain my problem:
I've been trying to login to Facebook with extended permissions on CocoonJS for about two weeks and I'm completely unable to do it... I can successfully login with basic permissions and everything works as expected, but I can't figure out how to request for extended permissions... When calling the Cocoon's FB login with the optional params, only the basic permissions are requested, so actually it seems that Cocoon (or FB) ignores the extended requests:
var socialService = CocoonJS.Social.Facebook.getSocialInterface();
socialService.login(function(loggedIn, error) {
if (error) {
console.error("login error: " + error.message);
}else if (loggedIn){
console.log("login suceeded");
CocoonJS.Social.Facebook.getLoginStatus(function(response) {
if (response.status === 'connected')
CocoonJS.Social.Facebook.api("/me/permissions",
function (response) {
if (response && !response.error) {
console.log("Granted perms.: "+JSON.stringify(response));
}else{
console.log("ERROR: unable to retrieve permissions");
}
}
);
}
});
}, { 'scope': 'user_photos,publish_actions',return_scopes: true });
The thing is, the login function seems to work properly and the "login succeeded" log is printed, and so is the "Granted perms." log. However, it only shows the basic permissions, completely ignoring the 'user_photos' and the 'publish_actions' ones (they don't even appear in the retrieved list...
I tried calling the option with 'scope', with scope, with 'perms'... but nothing changes the result. I've asked in the CocoonJS forums, I've been googling for two weeks, tried different solutions, different Facebook accounts, even tried hardcoding the extended params in the CocoonJS's FB login function (which result in crash), but nothing works...
Anyone knows how to achieve it?
Thanks in advance for your time and effort!
CocoonJS parses the 'scope' parameter as a string with comma separated values. But these permission values are used with a readonly session login. Facebook has deprecated logging in with the "publish_actions" permission and suggests that an app should request the bare minimum of read permissions during login and then request any additional or publish permissions when a person actually needs them.
I recommend that you request extended permissions this way:
CocoonJS.Social.Facebook.requestAdditionalPermissions("publish", "publish_actions", function(response) {
callback(response.error ? false : true);
});

Categories