Forgot to add callback-files

This commit is contained in:
Kasper Rynning-Tønnesen
2016-09-06 14:49:51 +02:00
parent 9a291c065c
commit 38817162b3
3 changed files with 51 additions and 0 deletions

10
php/callback.html Normal file
View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Zöff OAuth Callback</title>
<script type="text/javascript" src="/static/dist/callback.min.js"></script>
<meta charset="UTF-8"/>
</head>
<body>
</body>
</html>

1
static/dist/callback.min.js vendored Normal file
View File

@@ -0,0 +1 @@
!function(){function e(e){var t,o=e.substring(1).split("&"),n={};for(var a in o)t=o[a].split("="),2==t.length&&(n[t[0]]=t[1]);return n}window.addEventListener("load",function(){var t,o,n,a=e(window.location.hash),i=window.location.protocol+"//"+window.location.hostname+"/o_callback";if(a.spotify)t="b934ecdd173648f5bcd38738af529d58",o="token",n="playlist-read-private playlist-read-collaborative user-read-private",state=a.nonce,window.location.href="https://accounts.spotify.com/authorize?client_id="+t+"&scope="+n+"&show_dialog=false&response_type="+o+"&redirect_uri="+i+"&state="+state;else if(a.youtube)t="944988770273-butsmlr1aotlsskk8lmgvh0etqqekigf.apps.googleusercontent.com",o="token",n="https://www.googleapis.com/auth/youtube",state=a.nonce,window.location.href="https://accounts.google.com/o/oauth2/v2/auth?client_id="+t+"&response_type="+o+"&state="+state+"&redirect_uri="+i+"&scope="+n;else{var s=e(window.location.hash);window.opener.callback(s)}})}();

40
static/js/callback.js Normal file
View File

@@ -0,0 +1,40 @@
window.addEventListener("load", function(){
var query = getQueryHash(window.location.hash);
var redirect = window.location.protocol + "//" + window.location.hostname + "/o_callback";
var client_id;
var response;
var scope;
if(query.spotify){
client_id = "b934ecdd173648f5bcd38738af529d58";
response = "token";
scope = "playlist-read-private playlist-read-collaborative user-read-private";
state = query.nonce;
window.location.href = "https://accounts.spotify.com/authorize?client_id=" + client_id + "&scope=" + scope + "&show_dialog=false&response_type=" + response + "&redirect_uri=" + redirect + "&state=" + state;
} else if (query.youtube) {
client_id = "944988770273-butsmlr1aotlsskk8lmgvh0etqqekigf.apps.googleusercontent.com";
response = "token";
scope = "https://www.googleapis.com/auth/youtube";
state = query.nonce;
//window.opener.callback(query);
window.location.href = "https://accounts.google.com/o/oauth2/v2/auth?client_id=" + client_id + "&response_type=" + response + "&state=" + state + "&redirect_uri=" + redirect + "&scope=" + scope;
} else {
var query_parameters = getQueryHash(window.location.hash);
window.opener.callback(query_parameters);
}
});
function getQueryHash(url){
var temp_arr = url.substring(1).split("&");
var done_obj = {};
var splitted;
for(var i in temp_arr) {
splitted = temp_arr[i].split("=");
if(splitted.length == 2) {
done_obj[splitted[0]] = splitted[1];
}
}
return done_obj;
}