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

Single token per application #8

Open
dancingfire opened this issue May 7, 2021 · 4 comments
Open

Single token per application #8

dancingfire opened this issue May 7, 2021 · 4 comments
Assignees

Comments

@dancingfire
Copy link

Not sure how best to go about asking this question so I'll ask it here. First off tho, thanks for your work on this project.

I'm using this system to talk to Dropbox on behalf of an entire application. When using the token method to setup communication with Dropbox, the Auth:User is used to store the token. I only need one, so I'd like to override this once for the entire app. I could fork the code and change a few lines of code, but wondering if this is already handled in some other way? If not, would it be useful for me to submit a pull whereby there's a new config settings that is the AuthID to be used, and if this is set, that is used instead of the AuthID?

I'm not very familiar with the process of contributing to open source projects...

@rabol
Copy link

rabol commented Jun 21, 2021

https://dcblog.dev/docs/laravel-dropbox/introduction/install

generate your key in the Drop box console
add

DROPBOX_ACCESS_TOKEN=

to your .env

@dancingfire
Copy link
Author

Thanks - my understanding is that Dropbox is turning off the long-term identity tokens that this method relies on, so I was angling for a way that short term tokens could be renewed for a specific userID, not for the userID of the person who is logged in. Same as the above approach, but there would be a DROPBOX_TOKEN_USER_ID that would be set to an existing user of the application and always used for the Dropbox login, no matter which actual user was logged in.

@rabol
Copy link

rabol commented Jun 23, 2021

Yes, Dropbox is dropping long terms tokens, but... I believe that this package uses the 'refresh_token' identity to renew the short-live token, but...

there is either some documentation missing or the 'refresh' feature does not work

e.g Dropbox::isConnected() returns true, but then if you try to access folders Dropbox throws an error saying that the token has expired.

I'm trying to figure out how it should work as I need the 'auto-refresh' in my app

@rabol
Copy link

rabol commented Jun 23, 2021

I think this is working :)

In a controller:

    public function index()
    {
        if (!Dropbox::isConnected()) {
            return redirect(config('dropbox.redirectUri'));
        } else {
            $token = Dropbox::getTokenData();
            $date = new Carbon;
            if($date > $token->expires_in) {
                if(is_null(Dropbox::getAccessToken()))
                {
                    return redirect(config('dropbox.redirectUri'));
                }
            }
        }

        //display user details
        $user_data = Dropbox::post('users/get_current_account');
        return view('empty')->with('userdata', $user_data);
    }

@dcblogdev dcblogdev self-assigned this Dec 14, 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

3 participants