public class DbxWebAuthNoRedirect extends Object
DbxWebAuth
class instead.
Eventually yields an access token that can be used with DbxClient
to make
Dropbox API calls. You typically only need to do this for a user when they first use your
application. Once you have an access token for that user, it remains valid for years.
Example:
String userLocale = ...DbxRequestConfig
requestConfig = new DbxRequestConfig("text-edit/0.1", userLocale);DbxAppInfo
appInfo = DbxAppInfo.Reader.readFromFile("api.app"); DbxWebAuthNoRedirect webAuth = new DbxWebAuthNoRedirect(requestConfig, appInfo); String authorizeUrl = webAuth.start(); System.out.println("1. Go to " + authorizeUrl); System.out.println("2. Click \"Allow\" (you might have to log in first)."); System.out.println("3. Copy the authorization code."); System.out.print("Enter the authorization code here: "); String code = new BufferedReader(new InputStreamReader(System.in)).readLine(); if (code == null) return; code = code.trim();DbxAuthFinish
authFinish = webAuth.finish(code);DbxClient
client = new DbxClient(requestConfig, authFinish.accessToken);
Constructor and Description |
---|
DbxWebAuthNoRedirect(DbxRequestConfig requestConfig,
DbxAppInfo appInfo) |
Modifier and Type | Method and Description |
---|---|
DbxAuthFinish |
finish(String code)
Call this after the user has visited the authorizaton URL and copy/pasted the authorization
code that Dropbox gave them.
|
String |
start()
Start authorization.
|
public DbxWebAuthNoRedirect(DbxRequestConfig requestConfig, DbxAppInfo appInfo)
appInfo
- Your application's Dropbox API information (the app key and secret).public String start()
If they choose to grant access, they will be shown an "authorization code", which they
need to copy/paste back into your app, at which point you can call finish(java.lang.String)
to get an
access token.
public DbxAuthFinish finish(String code) throws DbxException
code
- The authorization code shown to the user when they clicked "Allow" on the authorization
page on the Dropbox website.DbxException
Copyright © 2015. All rights reserved.