We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
TC888
3 years agoExplorer | Level 3
Java SDK: authorizing with a refresh token, getting "no auth function available for given request"
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.
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.
- Greg-DBDropbox Staff
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.
- TC888Explorer | Level 3
That did the trick. Thanks.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 6 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!