Hello.js是一个客户端JavaScript框架,用于实现OAuth2认证。支持现有多个OAuth服务。
示例代码:
hello.init({ facebook : FACEBOOK_CLIENT_ID, windows : WINDOWS_CLIENT_ID, google : GOOGLE_CLIENT_ID},{redirect_uri:'redirect.html'});hello.on('auth.login', function(auth){// call user information, for the given networkhello( auth.network ).api( '/me' ).then( function(r){// Inject it into the containervar label = document.getElementById( "profile_"+ auth.network );if(!label){label = document.createElement('div');label.id = "profile_"+auth.network;document.getElementById('profile').appendChild(label);}label.innerHTML = '<img src="'+ r.thumbnail +'" /> Hey '+r.name;});});
评论