SIGN IN SIGN UP

Welcome to the AWS Code Examples Repository. This repo contains code examples used in the AWS documentation, AWS SDK Developer Guides, and more. For more information, see the Readme.md file below.

0 0 17 Java
2019-02-09 15:38:20 -08:00
<?php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
2019-02-09 15:38:20 -08:00
/*
* For more information about creating a WorkDocs application see the WorkDocs Developer Guide at
* https://docs.aws.amazon.com/workdocs/latest/developerguide/wd-auth-user.html
*
*/
// snippet-start:[workdocs.php.get_authorization_token.complete]
// snippet-start:[workdocs.php.get_authorization_token.import]
require 'vendor/autoload.php';
2019-02-09 15:38:20 -08:00
use GuzzleHttp\Client as httpClient;
2019-02-09 15:38:20 -08:00
// snippet-end:[workdocs.php.get_authorization_token.import]
2019-02-09 16:06:58 -08:00
// snippet-start:[workdocs.php.get_authorization_token.main]
2019-02-16 02:57:48 -08:00
$appId = 'appid';
$redirectUri = 'https://';
2019-02-16 02:57:48 -08:00
$url = "https://auth.amazonworkdocs.com/oauth?app_id=" . $appId . "&auth_type=ImplicitGrant&redirect_uri="
. $redirectUri . "&scopes=workdocs.content.read&state=xyz";
2019-02-09 15:38:20 -08:00
echo "<p>Url = <a href = '" . $url . "' target='_blank'>Request Authentication token</a></p>";
echo "<ol>";
echo "<li>Click on Link above</li>";
echo "<li>Enter the Amazon WorkDocs site name. Note that it is case sensitive.</li>";
echo "<li>Login to your Amazon WorkDocs site </li>";
echo "<li>To Grant or deny your application access to Amazon WorkDocs, select <b>Accept</b></li>";
echo "<li>Copy the URL you are taken</li>";
echo "<li>Save the string after <b>access_token=</b> and <b>region=</b></li>";
echo "</ol>";
2019-04-09 17:45:01 -07:00
echo "<p> For more information about Authentication and Access Control for User Applications see ";
2019-02-09 15:38:20 -08:00
echo "<a href='https://docs.aws.amazon.com/workdocs/latest/developerguide/wd-auth-user.html'>";
echo "Amazon WorkDocs Developer Guide</a></p>";
2019-02-09 15:38:20 -08:00
$guzzle = new httpClient([
'base_uri' => $url
]);
$response = $guzzle->request('GET');
2019-02-09 15:38:20 -08:00
// snippet-end:[workdocs.php.get_authorization_token.main]
// snippet-end:[workdocs.php.get_authorization_token.complete]
// snippet-sourceauthor:[jschwarzwalder (AWS)]