PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 1.4.2
JetBackup – Backup, Restore & Migrate v1.4.2
3.1.22.3 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.8.1 1.4.9 1.5.0 1.5.1 1.5.1.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 1.6.10 1.6.11 1.6.12 1.6.13 1.6.15 1.6.5.1 1.6.8.8 1.6.9 1.6.9.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7.5 2.0.8.7 2.0.9.11 2.0.9.14 2.0.9.15 2.0.9.6 2.0.9.7 2.0.9.9 3.1.10.7 3.1.11.1 3.1.12.3 3.1.13.4 3.1.14.17 3.1.15.4 3.1.16.1 3.1.17.5 3.1.18.10 3.1.18.8 3.1.18.9 3.1.19.8 3.1.20.3 3.1.21.3 3.1.7.9 3.1.9.2 trunk 1.1.90 1.1.91 1.2.0 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2
backup / com / lib / Dropbox / WebAuthBase.php
backup / com / lib / Dropbox Last commit date
Exception 5 years ago WebAuthException 5 years ago certs 5 years ago AppInfo.php 5 years ago AppInfoLoadException.php 5 years ago ArrayEntryStore.php 5 years ago AuthBase.php 5 years ago AuthInfo.php 5 years ago AuthInfoLoadException.php 5 years ago Checker.php 5 years ago Client.php 5 years ago Curl.php 5 years ago CurlStreamRelay.php 5 years ago DeserializeException.php 5 years ago DropboxMetadataHeaderCatcher.php 5 years ago Exception.php 5 years ago Host.php 5 years ago HttpResponse.php 5 years ago OAuth1AccessToken.php 5 years ago OAuth1Upgrader.php 5 years ago Path.php 5 years ago RequestUtil.php 5 years ago RootCertificates.php 5 years ago SSLTester.php 5 years ago Security.php 5 years ago StreamReadException.php 5 years ago Util.php 5 years ago ValueStore.php 5 years ago WebAuth.php 5 years ago WebAuthBase.php 5 years ago WebAuthNoRedirect.php 5 years ago WriteMode.php 5 years ago autoload.php 5 years ago strict.php 5 years ago
WebAuthBase.php
120 lines
1 <?php
2 namespace Dropbox;
3
4 /**
5 * The base class for the two auth options.
6 */
7 class WebAuthBase extends AuthBase
8 {
9 // protected function _getAuthorizeUrl($redirectUri, $state)
10 // {
11 // return RequestUtil::buildUrlForGetOrPut(
12 // $this->userLocale,
13 // $this->appInfo->getHost()->getWeb(),
14 // "1/oauth2/authorize",
15 // array(
16 // "client_id" => $this->appInfo->getKey(),
17 // "response_type" => "code",
18 // "redirect_uri" => $redirectUri,
19 // "state" => $state,
20 // ));
21 // }
22
23 /* Dropbox api 2*/
24 protected function _getAuthorizeUrl($redirectUri, $state)
25 {
26 return RequestUtil::buildUrlForGetOrPut(
27 $this->userLocale,
28 $this->appInfo->getHost()->getWeb(),
29 "oauth2/authorize",
30 array(
31 "client_id" => $this->appInfo->getKey(),
32 "response_type" => "code",
33 "redirect_uri" => $redirectUri,
34 "state" => $state,
35 ));
36 }
37
38 protected function _finish($code, $originalRedirectUri)
39 {
40 // This endpoint requires "Basic" auth.
41 $clientCredentials = $this->appInfo->getKey().":".$this->appInfo->getSecret();
42 $authHeaderValue = "Basic ".base64_encode($clientCredentials);
43
44 $response = RequestUtil::doPostWithSpecificAuth(
45 $this->clientIdentifier, $authHeaderValue, $this->userLocale,
46 $this->appInfo->getHost()->getApi(),
47 "oauth2/token",
48 array(
49 "grant_type" => "authorization_code",
50 "code" => $code,
51 "redirect_uri" => $originalRedirectUri,
52 ));
53
54 if ($response->statusCode !== 200) throw RequestUtil::unexpectedStatus($response);
55
56 $parts = RequestUtil::parseResponseJson($response->body);
57
58 if (!array_key_exists('token_type', $parts) || !is_string($parts['token_type'])) {
59 throw new Exception_BadResponse("Missing \"token_type\" field.");
60 }
61 $tokenType = $parts['token_type'];
62 if (!array_key_exists('access_token', $parts) || !is_string($parts['access_token'])) {
63 throw new Exception_BadResponse("Missing \"access_token\" field.");
64 }
65 $accessToken = $parts['access_token'];
66 if (!array_key_exists('uid', $parts) || !is_string($parts['uid'])) {
67 throw new Exception_BadResponse("Missing \"uid\" string field.");
68 }
69 $userId = $parts['uid'];
70
71 if ($tokenType !== "Bearer" && $tokenType !== "bearer") {
72 throw new Exception_BadResponse("Unknown \"token_type\"; expecting \"Bearer\", got "
73 .Util::q($tokenType));
74 }
75
76 return array($accessToken, $userId);
77 }
78
79 // protected function _finish($code, $originalRedirectUri)
80 // {
81 // // This endpoint requires "Basic" auth.
82 // $clientCredentials = $this->appInfo->getKey().":".$this->appInfo->getSecret();
83 // $authHeaderValue = "Basic ".base64_encode($clientCredentials);
84
85 // $response = RequestUtil::doPostWithSpecificAuth(
86 // $this->clientIdentifier, $authHeaderValue, $this->userLocale,
87 // $this->appInfo->getHost()->getApi(),
88 // "1/oauth2/token",
89 // array(
90 // "grant_type" => "authorization_code",
91 // "code" => $code,
92 // "redirect_uri" => $originalRedirectUri,
93 // ));
94
95 // if ($response->statusCode !== 200) throw RequestUtil::unexpectedStatus($response);
96
97 // $parts = RequestUtil::parseResponseJson($response->body);
98
99 // if (!array_key_exists('token_type', $parts) || !is_string($parts['token_type'])) {
100 // throw new Exception_BadResponse("Missing \"token_type\" field.");
101 // }
102 // $tokenType = $parts['token_type'];
103 // if (!array_key_exists('access_token', $parts) || !is_string($parts['access_token'])) {
104 // throw new Exception_BadResponse("Missing \"access_token\" field.");
105 // }
106 // $accessToken = $parts['access_token'];
107 // if (!array_key_exists('uid', $parts) || !is_string($parts['uid'])) {
108 // throw new Exception_BadResponse("Missing \"uid\" string field.");
109 // }
110 // $userId = $parts['uid'];
111
112 // if ($tokenType !== "Bearer" && $tokenType !== "bearer") {
113 // throw new Exception_BadResponse("Unknown \"token_type\"; expecting \"Bearer\", got "
114 // .Util::q($tokenType));
115 // }
116
117 // return array($accessToken, $userId);
118 // }
119 }
120