Upgrade twig to version 3 for php 8.1
[anoweco.git] / www / token.php
index 6a7fa81332960785cb0f4a5ef7e43b0b5728fd4e..67d6bb19fde0aa3c1f26c643bd2658e42d01cbfb 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 header('HTTP/1.0 500 Internal Server Error');
+header("Access-Control-Allow-Origin: *");
 
 function error($msg)
 {
@@ -78,8 +79,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'GET') {
     }
 
     header('HTTP/1.0 200 OK');
-    header('Content-type: application/x-www-form-urlencoded');
-    echo http_build_query(
+    header('Content-type: application/json');
+    echo json_encode(
         array(
             'me'        => $me,
             'client_id' => $client_id,
@@ -126,10 +127,11 @@ if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         )
     );
     header('HTTP/1.0 200 OK');
-    header('Content-type: application/x-www-form-urlencoded');
-    echo http_build_query(
+    header('Content-type: application/json');
+    echo json_encode(
         array(
             'access_token' => $access_token,
+            'token_type' => 'Bearer',
             'me' => $me,
             'scope' => $scope
         )