Exemplo n.º 1
0
        // GET: /Home/Connect
        public async Task <DropboxClient> GetDropboxClient()
        {
            DropboxClient dropboxClient        = null;
            var           authorizationRequest = DropboxOAuth2Helper.GetAuthorizeUri(
                OAuthResponseType.Code,
                clientId,
                RedirectUri).ToString();

            Oauth2Helper oauth2Helper = new Oauth2Helper();
            string       code         = await oauth2Helper.GetCode(authorizationRequest, RedirectUri, "www.google.com", "return to app!!!");

            //获取code成功
            if (!string.IsNullOrEmpty(code))
            {
                string token = await AuthAsync(code);

                if (!string.IsNullOrEmpty(token))
                {
                    dropboxClient = new DropboxClient(token, new DropboxClientConfig("iMobieDriveDemo"));
                }
            }
            return(dropboxClient);
        }