Skip to content

Commit fbb48ec

Browse files
committed
:octocat: update get-token examples
1 parent e03900b commit fbb48ec

File tree

7 files changed

+35
-15
lines changed

7 files changed

+35
-15
lines changed

examples/get-token/Imgur.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* @license MIT
99
*/
1010

11-
use chillerlan\HTTP\Utils\MessageUtil;
1211
use chillerlan\OAuth\Providers\Imgur;
1312

1413
$ENVVAR ??= 'IMGUR';
@@ -46,7 +45,7 @@
4645
}
4746
// step 4: verify the token and use the API
4847
elseif(isset($_GET['granted']) && $_GET['granted'] === $name){
49-
echo '<pre>'.print_r(MessageUtil::decodeJSON($provider->me()), true).'</pre>'.
48+
echo '<pre>'.print_r($provider->me(), true).'</pre>'.
5049
'<textarea cols="120" rows="3" onclick="this.select();">'.
5150
$storage->getAccessToken($name)->toJSON().
5251
'</textarea>';

examples/get-token/LastFM.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* @license MIT
99
*/
1010

11-
use chillerlan\HTTP\Utils\MessageUtil;
1211
use chillerlan\OAuth\Providers\LastFM;
1312

1413
$ENVVAR ??= 'LASTFM';
@@ -38,7 +37,7 @@
3837
}
3938
// step 4: verify the token and use the API
4039
elseif(isset($_GET['granted']) && $_GET['granted'] === $name){
41-
echo '<pre>'.print_r(MessageUtil::decodeJSON($provider->me()), true).'</pre>'.
40+
echo '<pre>'.print_r($provider->me(), true).'</pre>'.
4241
'<textarea cols="120" rows="3" onclick="this.select();">'.
4342
$provider->getAccessTokenFromStorage()->toJSON().
4443
'</textarea>';

examples/get-token/MailChimp.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* @license MIT
99
*/
1010

11-
use chillerlan\HTTP\Utils\MessageUtil;
1211
use chillerlan\OAuth\Providers\MailChimp;
1312

1413
$ENVVAR ??= 'MAILCHIMP';
@@ -44,7 +43,7 @@
4443
}
4544
// step 4: verify the token and use the API
4645
elseif(isset($_GET['granted']) && $_GET['granted'] === $name){
47-
echo '<pre>'.print_r(MessageUtil::decodeJSON($provider->me()), true).'</pre>'.
46+
echo '<pre>'.print_r($provider->me(), true).'</pre>'.
4847
'<textarea cols="120" rows="3" onclick="this.select();">'.
4948
$provider->getAccessTokenFromStorage()->toJSON().
5049
'</textarea>';

examples/get-token/_flow-oauth1.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
* @license MIT
99
*/
1010

11-
use chillerlan\HTTP\Utils\MessageUtil;
12-
1311
/**
1412
* @var \chillerlan\OAuth\Core\OAuth1Interface $provider
1513
* @var array|null $PARAMS
@@ -32,7 +30,7 @@
3230
}
3331
// step 4: verify the token and use the API
3432
elseif(isset($_GET['granted']) && $_GET['granted'] === $name){
35-
echo '<pre>'.print_r(MessageUtil::decodeJSON($provider->me()), true).'</pre>'.
33+
echo '<pre>'.print_r($provider->me(), true).'</pre>'.
3634
'<textarea cols="120" rows="3" onclick="this.select();">'.
3735
$provider->getAccessTokenFromStorage()->toJSON().
3836
'</textarea>';

examples/get-token/_flow-oauth2-no-state.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
* @license MIT
99
*/
1010

11-
use chillerlan\HTTP\Utils\MessageUtil;
12-
1311
/**
1412
* @var \chillerlan\OAuth\Core\OAuth2Interface $provider
1513
* @var array|null $PARAMS
@@ -33,7 +31,7 @@
3331
}
3432
// step 4: verify the token and use the API
3533
elseif(isset($_GET['granted']) && $_GET['granted'] === $name){
36-
echo '<pre>'.print_r(MessageUtil::decodeJSON($provider->me()), true).'</pre>'.
34+
echo '<pre>'.print_r($provider->me(), true).'</pre>'.
3735
'<textarea cols="120" rows="3" onclick="this.select();">'.
3836
$provider->getAccessTokenFromStorage()->toJSON().
3937
'</textarea>';

examples/get-token/_flow-oauth2.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
* @license MIT
99
*/
1010

11-
use chillerlan\HTTP\Utils\MessageUtil;
12-
1311
/**
1412
* @var \chillerlan\OAuth\Core\OAuth2Interface $provider
1513
* @var array|null $PARAMS
@@ -33,7 +31,7 @@
3331
}
3432
// step 4: verify the token and use the API
3533
elseif(isset($_GET['granted']) && $_GET['granted'] === $name){
36-
echo '<pre>'.print_r(MessageUtil::decodeJSON($provider->me()), true).'</pre>'.
34+
echo '<pre>'.print_r($provider->me(), true).'</pre>'.
3735
'<textarea cols="120" rows="3" onclick="this.select();">'.
3836
$provider->getAccessTokenFromStorage()->toJSON().
3937
'</textarea>';

public/index.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* OAuth test entry point
4+
*
5+
* @created 22.03.2024
6+
* @author smiley <smiley@chillerlan.net>
7+
* @copyright 2024 smiley
8+
* @license MIT
9+
*/
10+
11+
// use this with caution only in case something goes terribly wrong
12+
#error_reporting(E_ALL&~E_DEPRECATED);
13+
#ini_set('display_errors', 1);
14+
15+
// the path to your project's autoloader, e.g. "/var/www/vendor/autoload.php"
16+
$AUTOLOADER = __DIR__.'/../vendor/autoload.php';
17+
// the path to your config directory (writable, 0777), e.g. "/home/web-user/.oauth-config"
18+
$CFGDIR = __DIR__.'/../.config/';
19+
// the name of the .env file
20+
$ENVFILE = '.env';
21+
// an optional prefix for the provider variables in the .env
22+
$ENVVAR = null;
23+
// optional scopes for OAuth2 providers
24+
$SCOPES = null;
25+
26+
require_once __DIR__.'/../examples/get-token/GitHub.php';
27+
28+
29+

0 commit comments

Comments
 (0)