public function __construct(Dropbox $dropbox)
{
$this->api_client = $dropbox->api();
$this->content_client = $dropbox->content();
$this->access_token = session('access_token');
}
public function dashboard()
{
return view('admin.dashboard');
}
public function user(){
//dd($this->access_token);
$response = $this->api_client->request('POST', '/2/users/get_current_account', [
'headers' => [
'Authorization' => 'Bearer ' . '$this->access_token'
]
]);
$user = json_decode($response->getBody(), true);
$page_data = [
'user' => $user
];
return view('admin.user', $page_data);
}
access_token returns null and yells error: Invalid authorization value in HTTP header "Authorization": "Bearer"
But when I hard code the access_token generated from the developers portal it works fine.
Is there a way to get the access token dynamically ?
Thanks in Advance