Forum Discussion

Tomtit's avatar
Tomtit
Explorer | Level 3
3 years ago

Missing query parameter 'responseUri'

I making MVC application and trying to refresh token.

 

 

const string redirectUrl = "https://www.dropbox.com/1/oauth2/redirect_receiver";
           // string oauthUrl = $@"https://www.dropbox.com/1/oauth2/authorize?response_type=token&redirect_uri={redirectUrl}&client_id={AppKey}";
            
            string oauth2State;
            oauth2State = Guid.NewGuid().ToString("N");
            Uri authorizeUri =  DropboxOAuth2Helper.GetAuthorizeUri(OAuthResponseType.Token, ApiKey, redirectUrl, state: oauth2State);

            OAuth2Response tokenResult = await DropboxOAuth2Helper.ProcessCodeFlowAsync(authorizeUri, ApiKey, ApiSecret,null,oauth2State);
           

 

End getting error: The responseUri is missing a code value in the query component

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    Tomtit, Would be much easier if you start with some simple test code (something like shown here). 🙂 Once you got it running, you can play with different code modifications there.

    It's more automated when redirect URI points to local address rather external one for standalone local application. In referred example such URI is calculated here and is "extended" from local host (defined little above). The same URI (i.e. http://127.0.0.1:52475/authorize for particular example) should be registered for your application to be acceptable for Dropbox (security measure). As you can see in the example, authorizeURI (generated here) is used for launching your system browser rather than processing with API further (i.e. it's web address, not a API call or parameter of such call). In your post you are trying incorrect processing in the same context! The result from link confirmation (made by hand) gets received as a result of redirect handling (in the particular example in 2 steps - in HandleOAuth2Redirect and HandleJSRedirect functions bodies). 😉

    Hope this gives direction.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    Tomtit Like Здравко said, I also recommend starting with an unmodified sample app to see that working first, before making changes or implementing your own.

     

    Anyway, as they pointed out, your code that you shared here is incorrect because it is passing the authorization URL itself to ProcessCodeFlowAsync. That won't work because the authorization URI is the location of the web page where the user needs to manually authorize the app once. It's the resulting redirect URI (containing the authorization code) that you should pass to the responseUri parameter of ProcessCodeFlowAsync, like I described in your other thread. (Alternatively, you can pass just the authorization code string as the 'code' parameter.)

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,951 PostsLatest Activity: 30 minutes ago
352 Following

If 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!