You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dropbox introduces, effective on September, 30 2021, a new policy for OAuth2 token based authentication. It impacts all new applications as well as being suggested for existing apps. You can [read more about the change applied and how it impacts the authentication proces](https://dropbox.tech/developers/migrating-app-permissions-and-access-tokens#updating-access-token-type)
100
-
101
-
In short, the persistent, long lived tokens are being replaced with short lived tokens, which are valid for up to a few hours. With the current approach the application has to revalidate permission by executing a full handshake involving an interactive user to make a new token, which will expire.
93
+
# For backwards compatibility, the following also works:
Apps that require background ('offline') access but have not yet implemented refresh tokens will be impacted.
97
+
##### Integration with Rails
104
98
105
-
To keep “offline” access in the background the application must change authentication strategy and obtain a new token every time the old one expires with a simplified `refresh` procedure. The app performing a full token generation (the first step) must ask for special “offline” mode which will generate, except regular authentication, an additional refresh token that can be reused for future quick re-refresh procedures. Thus the refresh token is important and has to be securely stored with the application, as it will be required every time the short term token expires.
99
+
If you have a Rails application, you might be interested in this [setup
To prevent the app to lose connectivity and access to Dropbox resources using the library following changes has to be applied:
108
102
109
-
####Implement own `DropboxApi::Token`
103
+
##### Using refresh tokens
110
104
111
-
Application must replace current fixed token if it has used one with a dynamic, secure store that updates every time a token expires. For that purpose a new class `DropboxApi::Token` has been introduced, which implements short lived tokens, and replaces current fixed string approach.
105
+
Access tokens are short-lived by default (as of September 30th, 2021),
106
+
applications that require long-lived access to the API without additional
107
+
interaction with the user should use refresh tokens.
112
108
113
-
Furthermore overriding the class on your own and implement `save_token` method allows to keep tokens within your application secure store or session data, every time needed.
114
-
115
-
```ruby
116
-
classMyDropboxToken < DropboxApi::Token
117
-
defsave_token(token)
118
-
# Implement your own store method, token is a `Hash` instance in here, easy to serialize:
119
-
puts'Token to be saved somewhere in the database', token
120
-
end
121
-
end
122
-
```
123
-
124
-
#### Obtaining the offline token
125
-
126
-
The application must obtain a new token for “offline use”.
127
-
In case of use of Authenticator approach, following change has to be applied:
109
+
The process is similar but a token refresh might seamlessly occur as you
110
+
perform API calls. When this happens you'll need to store the
111
+
new token hash if you want to continue using this session, you can use the
112
+
`on_token_refreshed` callback to do this.
128
113
129
114
```ruby
115
+
# 1. Get an authorization URL, requesting offline access type.
0 commit comments