I'm new at this, trying to hook up Box's API v2. I successfully set up a PHP client library, which I found thanks to the link in the first paragraph on developers.box.com/auth. I've read Box's walkthrough in full more than twice along with roughly 100,000 questions and replies here in regard to the matter. My problem occurs after the user redirects to Box's authorization page, enters his credentials and clicks on "Allow." The results vary according to my redirect\_uri and the url of my login page where I've put my client\_id and client\_secret: 1) If my redirect\_uri matches my <https://mysite.com/login_with_box>, the user redirects to that same url, obviously, which in turn sends the user back to Box's authorization page; and 2) if my redirect\_uri differs from <https://mysite.com/login_with_box> page, then the user successfully returns to my redirect\_uri, the url of which includes the 30-second code. I know that I'm close to figuring this out but don't know how to turn the code into a token in 30 seconds or less and use it to show the user's folders, files, info or whatever else. Many thanks for your consideration. Here's where I stand: 

```
// mysite.com/client.php:

// ...

case 'Box':
    $this->oauth_version = '2.0';
    $this->request_token_url = '';
    $this->dialog_url = 'https://api.box.com/oauth2/authorize?client_id={CLIENT_ID}&response_type=code&redirect_uri={REDIRECT_URI}&state={STATE}';

    $this->append_state_to_redirect_uri = '';
    $this->access_token_url = 'https://api.box.com/oauth2/token';
    $this->authorization_header = true;
    $this->url_parameters = false;
break;

// ...

```

---

```
// mysite.com/login_with_box.php:

// ...

$client->client_id = '[my_client_id]';
$client->client_secret = '[my_client_secret]';

if(($success = $client->Initialize())) {
    if(($success = $client->Process())) {
        if(strlen($client->access_token)) {
            $success = $client->CallAPI(
                'https://api.box.com/2.0/users/me', 
                'GET', array(), array('FailOnAccessError'=>true), $user);
        }
    }
    $success = $client->Finalize($success);
}

// ...

```