Class DbxWebAuthNoRedirect


  • @Deprecated
    public class DbxWebAuthNoRedirect
    extends java.lang.Object
    Deprecated.
    use DbxWebAuth instead with a DbxWebAuth.Request configured with no redirect URI (see DbxWebAuth.Request.Builder.withNoRedirect()).
    Does the OAuth web-based authorization flow for apps that can't provide a redirect URI (such as the command-line example apps that come with this SDK). If you're a normal website, use the DbxWebAuth class instead with a DbxWebAuth.Request configured to use a redirect URI.

    This class is deprecated and should no longer be used. Instead use DbxWebAuth and DbxWebAuth.Request.Builder.withNoRedirect() to start an OAuth web-based authorization flow without redirects.

    Eventually yields an access token that can be used with DbxClientV2 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);
    
     DbxClientV2 client = new DbxClientV2(requestConfig, authFinish.accessToken);
     
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      DbxAuthFinish finish​(java.lang.String code)
      Deprecated.
      Call this after the user has visited the authorizaton URL and copy/pasted the authorization code that Dropbox gave them.
      java.lang.String start()
      Deprecated.
      Start authorization.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DbxWebAuthNoRedirect

        public DbxWebAuthNoRedirect​(DbxRequestConfig requestConfig,
                                    DbxAppInfo appInfo)
        Deprecated.
        Parameters:
        appInfo - Your application's Dropbox API information (the app key and secret).
    • Method Detail

      • start

        public java.lang.String start()
        Deprecated.
        Start authorization. Returns a "authorization URL" on the Dropbox website that gives the lets the user grant your app access to their Dropbox account.

        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.

      • finish

        public DbxAuthFinish finish​(java.lang.String code)
                             throws DbxException
        Deprecated.
        Call this after the user has visited the authorizaton URL and copy/pasted the authorization code that Dropbox gave them.
        Parameters:
        code - The authorization code shown to the user when they clicked "Allow" on the authorization page on the Dropbox website.
        Throws:
        DbxException