Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chatwork is always asking user to grant permissions #1

Open
tuanpht opened this issue Feb 7, 2018 · 0 comments
Open

Chatwork is always asking user to grant permissions #1

tuanpht opened this issue Feb 7, 2018 · 0 comments

Comments

@tuanpht
Copy link

tuanpht commented Feb 7, 2018

Hello,
I am testing Chatwork Oauth2 with my app. It was successfully granted by user:

image

However, on next logins, Chatwork still asks user to grant permissions:

image

Example code:
cw-login.php

<?php
require __DIR__ . '/vendor/autoload.php';

use ChatWork\OAuth2\Client\ChatWorkProvider;

$provider = new ChatWorkProvider(
    getenv('CW_CLIENT_ID'),
    getenv('CW_CLIENT_SECRET'),
    getenv('CW_REDIRECT_URI')
);

$url = $provider->getAuthorizationUrl([
    'scope' => [
        'users.profile.me:read', 
        'rooms.all:read_write',
    ],
]);

echo "<a href='$url'>Login with chatwork</a>";

cw-login-callback.php

<?php
require __DIR__ . '/vendor/autoload.php';

use ChatWork\OAuth2\Client\ChatWorkProvider;
use GuzzleHttp\Client;
use League\OAuth2\Client\Grant\AuthorizationCode;
use League\OAuth2\Client\Grant\RefreshToken;

if (!empty($_GET['error'])) {
    die('User denied your app requests!');
}

if (empty($_GET['code'])) {
    die('Error: no code returned!');
}

$provider = new ChatWorkProvider(
	getenv('CW_CLIENT_ID'),
	getenv('CW_CLIENT_SECRET'),
	getenv('CW_REDIRECT_URI')
);

$accessToken = $provider->getAccessToken((string) new AuthorizationCode(), [
	'code' => $_GET['code'],
]);

echo 'access_token: ' . $accessToken->getToken() . PHP_EOL;

$resourceOwner = $provider->getResourceOwner($accessToken);

echo 'Resource owner: ';
print_r($resourceOwner->toArray());

I think, this issue is not related to this oauth2 client package, but I don't know where to get help.
Please give some advices. Thank you!

ada-u pushed a commit that referenced this issue Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant