cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Looking for some photography tips this holiday period? You can find some in our Photographers Group here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Java SDK: authorizing with a refresh token, getting "no auth function available for given request"

Java SDK: authorizing with a refresh token, getting "no auth function available for given request"

TC888
Explorer | Level 3
Go to solution

I'm trying to get authorization using refresh token to work in my project, but I'm having some trouble. This is a command line tool that will run as a cron job, so there shouldn't be any user interaction except once when setting up the configuration.

 

I start by maunally going to an authorization URL in a browser:
https://www.dropbox.com/oauth2/authorize?client_id=<removed for security>&response_type=code&token_access_type=offline

 

There, I authorize the app and get a code. Then I run the following Groovy script:

 

String appKey = '<removed for security>'
String appSecret = '<removed for security>'

DbxAppInfo appInfo = new DbxAppInfo(appKey, appSecret)

String accessCode = '<the code I got from the website>' 

DbxRequestConfig config = DbxRequestConfig.newBuilder(appKey).build();
DbxWebAuth webAuth = new DbxWebAuth(config, appInfo)
DbxAuthFinish authFinish = webAuth.finishFromCode(accessCode)
println authFinish.getAccessToken()
println authFinish.getRefreshToken()
println authFinish.getScope() // Returns account_info.read files.content.read files.metadata.read sharing.read sharing.write

 

That works fine, and I get an access token (which I don't think I should need since I'll be using the refresh token) and a refresh token.

I use those in this script, which is testing some of what the final product will need to do:

 

String folderUrl = '<the URL of a shared folder>'

String appKey = '<our app key>'
String accessToken = '<the access token retrieved in the previous script>'
String refreshToken = '<the refresh token retrieved in the previous script>'

DbxRequestConfig config = DbxRequestConfig.newBuilder(appKey).build();
DbxCredential credential = new DbxCredential(accessToken, 1, refreshToken, appKey)
DbxClientV2 client = new DbxClientV2(config, credential);

FolderLinkMetadata metadata = client.sharing().getSharedLinkMetadata(folderUrl)
println metadata

 

(There's actually more of that script, but for the sake of simplicity I truncated it where the error happens.)

 

On the getSharedLinkMetadata call, I get com.dropbox.core.oauth.DbxOAuthException: No auth function available for given request. Searching for that exception on Google, it seems to be pretty generic, so I'm not sure what the specific problem is.
Note that this works if, instead of a refresh token, I use an access token that I generate on the app console web page.
Are there any problems with how I'm doing this? If not, how should I begin troubleshooting?

 

Thanks in advance for the help.

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

Since you're not using PKCE, the app secret is required for the refresh process, so you'll need to set appSecret when making your DbxCredential​.

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

Since you're not using PKCE, the app secret is required for the refresh process, so you'll need to set appSecret when making your DbxCredential​.

TC888
Explorer | Level 3
Go to solution

That did the trick.  Thanks.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    TC888 Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?