PluginProbe ʕ •ᴥ•ʔ
JetBackup – Backup, Restore & Migrate / 1.3.4
JetBackup – Backup, Restore & Migrate v1.3.4
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 / WebAuthNoRedirect.php
backup / com / lib / Dropbox Last commit date
Exception 6 years ago WebAuthException 6 years ago certs 6 years ago AppInfo.php 6 years ago AppInfoLoadException.php 6 years ago ArrayEntryStore.php 6 years ago AuthBase.php 6 years ago AuthInfo.php 6 years ago AuthInfoLoadException.php 6 years ago Checker.php 6 years ago Client.php 6 years ago Curl.php 6 years ago CurlStreamRelay.php 6 years ago DeserializeException.php 6 years ago DropboxMetadataHeaderCatcher.php 6 years ago Exception.php 6 years ago Host.php 6 years ago HttpResponse.php 6 years ago OAuth1AccessToken.php 6 years ago OAuth1Upgrader.php 6 years ago Path.php 6 years ago RequestUtil.php 6 years ago RootCertificates.php 6 years ago SSLTester.php 6 years ago Security.php 6 years ago StreamReadException.php 6 years ago Util.php 6 years ago ValueStore.php 6 years ago WebAuth.php 6 years ago WebAuthBase.php 6 years ago WebAuthNoRedirect.php 6 years ago WriteMode.php 6 years ago autoload.php 6 years ago strict.php 6 years ago
WebAuthNoRedirect.php
83 lines
1 <?php
2 namespace Dropbox;
3
4 /**
5 * OAuth 2 code-based authorization for apps that can't provide a redirect URI, typically
6 * command-line example apps.
7 *
8 * Use {@link WebAuth::start()} and {@link WebAuth::getToken()} to guide your
9 * user through the process of giving your app access to their Dropbox account. At the end, you
10 * will have an {@link AccessToken}, which you can pass to {@link Client} and start making
11 * API calls.
12 *
13 * Example:
14 *
15 * <code>
16 * use \Dropbox as dbx;
17 * $appInfo = dbx\AppInfo::loadFromJsonFile(...);
18 * $clientIdentifier = "my-app/1.0";
19 * $webAuth = new dbx\WebAuthNoRedirect($appInfo, $clientIdentifier, ...);
20 *
21 * $authorizeUrl = $webAuth->start();
22 *
23 * print("1. Go to: $authorizeUrl\n");
24 * print("2. Click "Allow" (you might have to log in first).\n");
25 * print("3. Copy the authorization code.\n");
26 * print("Enter the authorization code here: ");
27 * $code = \trim(\fgets(STDIN));
28 *
29 * try {
30 * list($accessToken, $userId) = $webAuth->finish($code);
31 * }
32 * catch (dbx\Exception $ex) {
33 * print("Error communicating with Dropbox API: " . $ex->getMessage() . "\n");
34 * }
35 *
36 * $client = dbx\Client($accessToken, $clientIdentifier, ...);
37 * </code>
38 */
39 class WebAuthNoRedirect extends WebAuthBase
40 {
41 /**
42 * Returns the URL of the authorization page the user must visit. If the user approves
43 * your app, they will be shown the authorization code on the web page. They will need to
44 * copy/paste that code into your application so your app can pass it to
45 * {@link finish}.
46 *
47 * See <a href="https://www.dropbox.com/developers/core/docs#oa2-authorize">/oauth2/authorize</a>.
48 *
49 * @return string
50 * An authorization URL. Direct the user's browser to this URL. After the user decides
51 * whether to authorize your app or not, Dropbox will show the user an authorization code,
52 * which the user will need to give to your application (e.g. via copy/paste).
53 */
54 function start()
55 {
56 return $this->_getAuthorizeUrl(null, null);
57 }
58
59 /**
60 * Call this after the user has visited the authorize URL returned by {@link start()},
61 * approved your app, was presented with an authorization code by Dropbox, and has copy/paste'd
62 * that authorization code into your app.
63 *
64 * See <a href="https://www.dropbox.com/developers/core/docs#oa2-token">/oauth2/token</a>.
65 *
66 * @param string $code
67 * The authorization code provided to the user by Dropbox.
68 *
69 * @return array
70 * A <code>list(string $accessToken, string $userId)</code>, where
71 * <code>$accessToken</code> can be used to construct a {@link Client} and
72 * <code>$userId</code> is the user ID of the user's Dropbox account.
73 *
74 * @throws Exception
75 * Thrown if there's an error getting the access token from Dropbox.
76 */
77 function finish($code)
78 {
79 Checker::argStringNonEmpty("code", $code);
80 return $this->_finish($code, null);
81 }
82 }
83