File: access_skydrive.vsp

package info (click to toggle)
virtuoso-opensource 7.2.5.1%2Bdfsg1-0.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 285,240 kB
  • sloc: ansic: 641,220; sql: 490,413; xml: 269,570; java: 83,893; javascript: 79,900; cpp: 36,927; sh: 31,653; cs: 25,702; php: 12,690; yacc: 10,227; lex: 7,601; makefile: 7,129; jsp: 4,523; awk: 1,697; perl: 1,013; ruby: 1,003; python: 326
file content (43 lines) | stat: -rw-r--r-- 1,941 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?vsp
  declare _params, _client_id, _client_secret, _return_url, _code, _url, _reqHeader, _retHeader, _body, _retValue, _json, _xml any;
  declare _display_name, _email varchar;

  _code := get_keyword ('code', params, '');
  _json := '{\"error\" : \"invalid_request\"}';
  if (_code <> '')
  {
    _client_id := (select a_key from OAUTH..APP_REG where a_name = 'SkyDrive API' and a_owner = 0);
    _client_secret := (select a_secret from OAUTH..APP_REG where a_name = 'SkyDrive API' and a_owner = 0);
    _return_url := sprintf ('http://%{WSHost}s/ods/access_skydrive.vsp', http_path());
    _url := 'https://login.live.com/oauth20_token.srf';
    _reqHeader := 'Content-Type: application/x-www-form-urlencoded\r\n';
    _body := sprintf ('code=%U&client_id=%U&client_secret=%U&redirect_uri=%U&grant_type=%U', _code, _client_id, _client_secret, _return_url, 'authorization_code');
    _retValue := http_client (url=>_url, http_method=>'POST', http_headers=>_reqHeader, body=>_body, n_redirects=>15);
    _json := replace (_retValue, '\n', '\\n');

    -- get owner info
    _params := subseq (ODS..json2obj (_retValue), 2);
    _url := sprintf ('https://apis.live.net/v5.0/me?access_token=%U', get_keyword ('access_token', _params));
    _retHeader := null;
    _retValue := http_client_ext (url=>_url, http_method=>'GET', headers =>_retHeader, n_redirects=>15);
    if (not ((_retHeader[0] like 'HTTP/1._ 4__ %') or (_retHeader[0] like 'HTTP/1._ 5__ %')))
    {
      _params := subseq (ODS..json2obj (_retValue), 2);
      _display_name := get_keyword ('name', _params);
    }
  }
?>
<html>
  <head>
  </head>
  <body>
    <script type="text/javascript">
      if (window.opener && window.opener.open && !window.opener.closed) {
        window.opener.ODRIVE.skydriveParams('<?vsp http (_json); ?>', '<?V _display_name ?>');
      } else {
        alert ('Opener not found');
      }
      window.close();
    </script>
  </body>
</html>