· 7 years ago · Jul 06, 2018, 04:54 AM
1<!doctype html>
2<html>
3<head>
4 <meta charset="utf-8">
5 <link rel="stylesheet" href="assets/css/app.css" type="text/css">
6</head>
7<body>
8<div id="result"></div>
9<!--<script src="https://maps.googleapis.com/maps/api/js?v=3&sensor=false&libraries=places"></script>-->
10<script type="text/javascript" src="assets/js/app.js"></script>
11</body>
12</html>
13
14/**
15 * OAUTH 2 LOGIN
16 */
17
18+function () {
19 var $CLIENT_CODE = 'fc8uhbwlo4niqhngrjsdl3tbp3cndpidfs61w77g';
20 var $CLIENT_ID = 'llsfdwZzO7qVHBzM4nhfcq1jFW2L8O';
21 var $CLIENT_SECRET = 'auaCKn8JWXQmSyYrl3PDi23klIhotp';
22
23 var $AUTHORIZATION_ENDPOINT = 'http://domain.dev/oauth/authorize';
24 var $TOKEN_ENDPOINT = 'http://domain.dev/oauth/token';
25
26
27 $.ajax({
28 url: $AUTHORIZATION_ENDPOINT + '?client_id=' + $CLIENT_ID + '&client_secret=' + $CLIENT_SECRET + '&response_type=code',
29 }).done(function (url) {
30 $('#result').html(url);
31 fetchSomething();
32 }).fail(function (errorThrown) {
33 console.log("Error" > errorThrown.responseText);
34 })
35
36
37 function fetchSomething() {
38 $.ajax({
39 type: 'POST',
40 url: $TOKEN_ENDPOINT + '?grant_type=authorization_code&code=' + $CLIENT_CODE,
41 }).done(function (success) {
42 console.log(success);
43 }).fail(function (error) {
44 console.log(error);
45 });
46 }
47}();
48
49$.ajax({
50 url: 'http://' + domain + '?oauth=token',
51 type: 'POST',
52 data: {
53 grant_type: grantType,
54 code: code,
55 client_id: clientID,
56 client_secret: clientSecret,
57 redirect_uri: redirect
58 }
59}).done(function (token) {
60 console.log(token);
61}).fail(function (fail) {
62 console.log(fail.responseJSON.error);
63});