Trending
WHO Report Warns Global Progress Against HIV and Hepatitis is Losing Momentum is trending now Plateau Records 441 Suspected Cholera Cases, 14 Deaths is trending now Hygiene: Reckitt launches nationwide hygiene challenge is trending now NASA Will Chase the August Eclipse With a Jet as Totality Crosses the Arctic and Spain is trending now Moon's thick crust could amplify elusive gravitational-wave signals is trending now Hidden charcoal reveals the true age of ancient cave paintings is trending now A Cockroach 'Collective Memory' Emerges From Their Social Networks, Study Suggests is trending now World Cup 2026: FIFA’s Goal of the tournament confirmed is trending now Real Madrid in trouble: Diomande puts Perez before the "thorny file" is trending now Zinedine Zidane: Former Real Madrid manager appointed as France head coach is trending now Burna Boy stopped speaking to me over rumours that I slept with his girlfriend – Shatta W… is trending now VMFA Aaron Siskind Award for Photography (US) is trending now WHO Report Warns Global Progress Against HIV and Hepatitis is Losing Momentum is trending now Plateau Records 441 Suspected Cholera Cases, 14 Deaths is trending now Hygiene: Reckitt launches nationwide hygiene challenge is trending now NASA Will Chase the August Eclipse With a Jet as Totality Crosses the Arctic and Spain is trending now Moon's thick crust could amplify elusive gravitational-wave signals is trending now Hidden charcoal reveals the true age of ancient cave paintings is trending now A Cockroach 'Collective Memory' Emerges From Their Social Networks, Study Suggests is trending now World Cup 2026: FIFA’s Goal of the tournament confirmed is trending now Real Madrid in trouble: Diomande puts Perez before the "thorny file" is trending now Zinedine Zidane: Former Real Madrid manager appointed as France head coach is trending now Burna Boy stopped speaking to me over rumours that I slept with his girlfriend – Shatta W… is trending now VMFA Aaron Siskind Award for Photography (US) is trending now
Technology

Dropbox como obter refresh token

Dropbox como obter refresh token

Infelizmente o access token do Dropbox é limitado à 4 horas. Mas é possível contornar isso utilizando do seu refresh token, que é um token que permite você obter um novo access token sempre que seu access token expirar. Note que ensinaremos como realizar o procedimento manualmente, após entender o fluxo de autenticação você pode adaptar para sua linguagem de programação preferida. Primeiramente acesse a página do seu app no Dropbox em https://www.dropbox.com/developers/apps e anote seu "App key" e "App secret", lembre-se de deixar habilitado como "Allow" a opção: Allow public clients (Implicit Grant & PKCE). Copie a url abaixo substituindo <App key> pelo "App key" que você anotou anteriormente: [https://www.dropbox.com/oauth2/authorize?token_access_type=offline&response_type=code&client_id=<App key>] Cole a url em seu navegador e entre com a conta no Dropbox que deseja utilizar como local de upload, autorize utilizar seu aplicativo nessa conta e anote o "Código de acesso gerado" pois precisaremos dele! Agora abra o prompt de comando para utilizar o comando curl a seguir: [curl https://api.dropbox.com/oauth2/token -d code=<Authorization Code> -d grant_type=authorization_code -u <App key>:<App secret>] Substitua <Authorization Code> pelo código de acesso anotado, também substitua <App key> e <App secret> pelos respectivos códigos do seu app anotado no inicio desse artigo. A saída do comando será algo como: [{"access_token": "sl.yyy...", "token_type": "bearer", "expires_in": 14400, "refresh_token": "xxx...", "scope": "account_info.read files.content.write files.metadata.read files.metadata.write", "uid": "9999", "account_id": "dbid:zzz..."}] Pronto agora você tem seu refresh token, exemplo: xxx... Com o refresh token você pode obter um novo access token sempre que ele expirar, para isso utilize do comando abaixo: [curl https://api.dropbox.com/oauth2/token -d refresh_token=<Refresh token> -d grant_type=refresh_token -d client_id=<App key> -d client_secret=<App secret>] Substitua <Refresh token> pelo código de refresh obtido, também substitua <App key> e <App secret> pelos respectivos códigos do seu app. A saída do comando será algo como: [{"access_token": "sl.yyy...", "token_type": "bearer", "expires_in": 14400}] Agora é só utilizar o access_token da resposta como seu access token para realizar upload em sua conta no Dropbox. Para mais informações acesse https://dropbox.tech/developers/using-oauth-2-0-with-offline-access .

View original source →

Related

More from Limon Tec