Open ghost opened 8 years ago
google+ auth codes is supported by the code. You can do client.auth_provider = 2;
to switch key type to google.
But how to generate google auth key i do not know. You can investigate it
yourself, i'm little busy for that.
2016-01-23 1:21 GMT+02:00 Zephyr Vi Britannia notifications@github.com:
Could you implement google+ as well?
— Reply to this email directly or view it on GitHub https://github.com/pulviscriptor/agario-client/issues/64.
Pulviscriptor please find a way to implement google+!
@pulviscriptor I have already attempted by looking at web requests to look for the auth key but I couldn't find it. At least tell us what requested url has the auth key?
@Zephyr-Vi I do not know URL and do not know is it hard or not to get it. You can look how "fun" it was searching FB URL https://github.com/pulviscriptor/agario-client/issues/42 When i will have some free time for it, i will look what i can do.
Relevent parts on agar.io script :
(function(a) { function b() { var a = document.createElement("script"); a.type = "text/javascript"; a.async = !0; a.src = "// apis.google.com/js/client:platform.js?onload=gapiAsyncInit"; var b = document.getElementsByTagName("script")[0]; b.parentNode.insertBefore(a, b); f = !0 } var d = {}, f = !1; c.gapiAsyncInit = function() { e(d).trigger("initialized") }; a.google = { oa: function() { b() }, ma: function(a, b) { c.gapi.client.load("plus", "v1", function() { console.log("fetching me profile"); gapi.client.plus.people.get({ userId: "me" }).execute(function(a) { b(a) }) }) } }; a.wa = function(a) { f || b(); "undefined" !== typeof gapi ? a() : e(d).bind("initialized", a) }; return a })(p); var Ec = function(a) { function b(a) { c.MC.doLoginWithGPlus(a); p.cache.login_info = [a, "google"]; p.I.M(a, "google") }
function d(a) {
g.userInfo.picture = a;
e(".agario-profile-picture").attr("src", a)
}
var f = null,
k = {
client_id: A.gplus_client_id,
cookie_policy: "single_host_origin",
scope: "profile email"
};
a.ea = {
Y: function() {
return f
},
init: function() {
var a = this,
b = g && "1" == g.loginIntent && "google"
== g.context; p.wa(function() { c.gapi.ytsubscribe.go("agarYoutube"); c.gapi.load("auth2", function() { f = c.gapi.auth2.init(k);
f.attachClickHandler(document.getElementById("gplusLogin"), {}, function(a) { console.log("googleUser : " + a) }, function(a) { console.log("failed to login in google plus: ", JSON.stringify(a, void 0, 2)) }); f.currentUser.listen(_.bind(a.va, a)); b && 1 == f.isSignedIn.get() && f.signIn() }) }) }, va: function(a) { if (f && a && f.isSignedIn.get() && !pb) { pb = !0; g.loginIntent = "1"; var e = a.getAuthResponse(), k = e.access_token; c.Y = e; console.log("loggedIn with G+!"); var h = a.getBasicProfile(); a = h.getImageUrl(); void 0 == a ? p.google.ma(e, function(a) { a.result.isPlusUser ? (a && d(a.image.url), b(k), a && (g.userInfo.picture = a.image.url), g.userInfo.socialId = h.getId(), Ma()) : (alert("Please add Google+ to your Google account and try again.\nOr you can login with another account."), c.logout()) }) : (d(a), g.userInfo.picture = a, g.userInfo.socialId = h.getId(), Ma(), b(k)); g.context = "google"; c.updateStorage() } }, pa: function() { f && (f.signOut(), pb = !1) } }; return a }(p); c.gplusModule = Ec; var ec = function() { p.ea.pa() }; c.logoutGooglePlus = ec;
More info about G+ api : https://developers.google.com/api-client-library/javascript/reference/referencedocs#gapiclientloadname--------version-callback
Le sam. 23 janv. 2016 à 11:31, pulviscriptor notifications@github.com a écrit :
@Zephyr-Vi https://github.com/Zephyr-Vi I do not know URL and do not know is it hard or not to get it. You can look how "fun" it was searching FB URL #42 https://github.com/pulviscriptor/agario-client/issues/42 When i will have some free time for it, i will look what i can do.
— Reply to this email directly or view it on GitHub https://github.com/pulviscriptor/agario-client/issues/64#issuecomment-174169179 .
I figured out how to do it myself. :P
Could you contribute and share the code so we can expand agario client script
@Zephyr-Vi You can just share URL or method how to obtain token and i will do the rest. Just if you want to share.
@pulviscriptor Could that url help?
@pulviscriptor This might be the solution for G+,
https://github.com/althjs/social-oauth-client#google and
https://github.com/laardee/serverless-authentication-google/blob/master/src/index.js PLZ give it some time as we all need it
@hassanila97 I can't implement it any time soon, can't find time to investigate how it works. If you/somebody can do it, that would be great.
@pulviscriptor Okay, I've investigated it so it works like this, also can you give me credit in the code for doing this so something like "//Thanks to Zephyr for telling me how it works (https://github.com/Zephyr-Vi)".
First we have to load the client_id and login_hint which is used in the request to get our agario token.
https://accounts.google.com/o/oauth2/auth?redirect_uri=storagerelay://http/agar.io?id=XXXXX&response_type=permission&scope=email profile openid&openid.realm=&client_id=XXXXX&ss_domain=http://agar.io&fetch_basic_profile=true
This url seems to be static which gives you a static "login_hint" but the "client_id" seems to change. The cookies sent it the request doesn't seem to effect it which believes me to think it is unneeded.
Which returns a html format:
<!DOCTYPE html>
<html>
<head>
<title>Connecting ...</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0">
<script src='https://ssl.gstatic.com/accounts/o/3403534109-storagerelay.js'></script>
</head>
<body>
<script type="text/javascript">
var done = function () {
window.close();
};
lso.relayAuthResponseByWebStorageEvent('http:\/\/agar.io', 'xxxxx', 'xxxx', {
"login_hint": "xxxx"
, "client_id": "xxxx"
}, done);
</script>
</body>
</html>
GET https://accounts.google.com/o/oauth2/iframerpc?action=issueToken&response_type=token id_token&scope=openid profile email&client_id=xxxx&login_hint=XXXXX&ss_domain=http://agar.io&origin=http://agar.io HTTP/1.1
Which returns a JSON object:
{"token_type":"Bearer","access_token":"XXXXXX","scope":"https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.me openid email profile","login_hint":"XXXXX","expires_in":3600,"id_token":"XXXX","session_state":{"extraQueryParams":{"authuser":"0"}}}
I did more research by looking into the code and the token used is called "access_token":
var e = a.getAuthResponse() , g = e.access_token;
No problem for me doing this. ;)
Great work
@pulviscriptor Szammi, henopied and I finally finished our google plus token finder(Couldnt think of the right word for it). I have no idea how to use github so henopied is working on adding it in a pull request
@DaAwesomeRazor Great! I'm bad at investigations of HTTP stuff and can't find free day for it.
@DaAwesomeRazor No credits for me figuring out the requests? :-1:
Could you implement google+ as well?