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

Can't Get Access Token In Wordpress #105

Closed
TendiF opened this issue Dec 11, 2017 · 0 comments
Closed

Can't Get Access Token In Wordpress #105

TendiF opened this issue Dec 11, 2017 · 0 comments

Comments

@TendiF
Copy link

TendiF commented Dec 11, 2017

I can't get the token even i click allow

use Kunnu\Dropbox\Dropbox;
use Kunnu\Dropbox\DropboxApp;
//Dropbox author
add_action('wp_ajax_dropbox_user_getauth', 'dropbox_user_getauth');
function dropbox_user_getauth(){
  // echo 'Dropbox Auth';
  session_start();
  require_once(plugin_dir_path(__FILE__).'vendor/autoload.php');

  //Configure Dropbox Application
  $app = new DropboxApp("xxxxxxxxx", "xxxxxxxxxxx");

  //Configure Dropbox service
  $dropbox = new Dropbox($app);
  //DropboxAuthHelper
  $authHelper = $dropbox->getAuthHelper();
  //Callback URL
  $callbackUrl = "https://dev.audiotext.com/wp-admin/admin-ajax.php?action=dropbox_user_getauth";
   // var_dump($authHelper);
   //Fetch the Authorization/Login URL
   $authUrl = $authHelper->getAuthUrl($callbackUrl);

   echo "<a target='_blank' href='" . $authUrl . "'>Log in with Dropbox</a>";

   if (isset($_GET['code']) && isset($_GET['state'])) {
    //Bad practice! No input sanitization!
    $code = $_GET['code'];
    $state = $_GET['state'];

   //Fetch the AccessToken
   $accessToken = $authHelper->getAccessToken($code, $state, $callbackUrl);

   echo $accessToken->getToken();
  }
}

someone know what my fault

i used localhost https anyway
==========HERE MY ERROR LOG====================
// if ($tokenInStore !== $csrfToken) {
// throw new DropboxClientException("Invalid CSRF Token. CSRF Token Mismatch.");
// }
AFTER I REMOVE THAT DECISION I GET TOKEN AND IT CAN BE USE 🤣

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

2 participants