Skip to content

Commit a7d8456

Browse files
authored
Merge pull request #4 from codebar-ag/feature-updated
Fix Authentication refreshToken Bug
2 parents 73aa600 + 365440f commit a7d8456

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

phpstan-baseline.neon

Whitespace-only changes.

phpstan.neon.dist

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
includes:
2+
- phpstan-baseline.neon
3+
4+
parameters:
5+
level: 4
6+
paths:
7+
- src
8+
- config
9+
tmpDir: build/phpstan
10+
checkOctaneCompatibility: true
11+
checkModelProperties: true
12+

src/Actions/InstagramHandler.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public static function connector(): InstagramConnector
3535
if ($authenticator->hasExpired()) {
3636
$authenticator = $connector->refreshAccessToken($authenticator);
3737

38-
Cache::store(config('instagram.cache_store'))->put('instagram.authenticator', $serialized, now()->addDays(60));
38+
// @phpstan-ignore-next-line
39+
Cache::store(config('instagram.cache_store'))->put('instagram.authenticator', $authenticator->serialize(), now()->addDays(60));
3940
}
4041

4142
$connector->authenticate($authenticator);

src/Data/InstagramUser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function __construct(
2727
public string $username,
2828
public string $name,
2929
public string $account_type,
30-
public string $profile_picture_url,
30+
public ?string $profile_picture_url,
3131
public int $followers_count,
3232
public int $follows_count,
3333
public int $media_count,

src/Http/Controllers/InstagramController.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public function callback(Request $request)
3434

3535
$connector = new InstagramConnector;
3636
$shortLivedAuthenticator = $connector->getShortLivedAccessToken(code: $request->get('code'));
37-
$authenticator = $connector->getAccessToken(code: $shortLivedAuthenticator->accessToken);
38-
$serialized = $authenticator->serialize();
37+
$authenticator = $connector->getAccessToken(code: $shortLivedAuthenticator->accessToken); // @phpstan-ignore-line
38+
$serialized = $authenticator->serialize(); // @phpstan-ignore-line
3939

4040
Cache::store(config('instagram.cache_store'))->put('instagram.authenticator', $serialized, now()->addDays(60));
4141

@@ -50,8 +50,6 @@ public function callback(Request $request)
5050

5151
$json = $response->json();
5252

53-
ray($json);
54-
5553
Cache::store(config('instagram.cache_store'))->put('instagram.authenticated', $json, now()->addDays(60));
5654

5755
return response('Authenticated Instagram account: '.Arr::get($json, 'username'), 200);

src/Requests/Authentication/GetAccessTokenRequest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ public function __construct(protected string $code, protected OAuthConfig $oauth
3939
*
4040
* @return array{
4141
* grant_type: string,
42-
* code: string,
43-
* client_id: string,
42+
* access_token: string,
4443
* client_secret: string,
45-
* redirect_uri: string,
4644
* }
4745
*/
4846
public function defaultQuery(): array

0 commit comments

Comments
 (0)