cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We are making some updates so the Community might be down for a few hours on Monday the 11th of November. Apologies for the inconvenience and thank you for your patience. You can find out more 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: 

.NET SDK Invalid request while calling ProcessCodeFlowAsync

.NET SDK Invalid request while calling ProcessCodeFlowAsync

Ghislain Sommervogel
Helpful | Level 5
Go to solution

Hi Team,

I'm trying to setup a permanent connection (= a refreshToken process) to my app using OauthPKCE.

For this, I'm using the sample code provided here: https://github.com/dropbox/dropbox-sdk-dotnet/blob/main/dropbox-sdk-dotnet/Examples/OAuthPKCE/Progra...

I ran into a difficulty at this line:

      var tokenResult = await OAuthFlow.ProcessCodeFlowAsync(redirectUri, ApiKey, RedirectUri.ToString(), state);

My redirectURI seems to be correct (something like http://127.0.0.1:52475/authorize?code=gAY-xxxxxxxxxxxxxxxxxx), but the subsequent call to ProcessCodeFlowAsync results in an exception (Dropbox.Api.OAuth2Exception: 'invalid_request'). Error description says "client secret is missing". I guess it has something to do with the "App secret" setting, but I couldn't find where to provide this information in ProcessCodeFlowAsync, nor in the above instructions.

Any idea? Thanks a lot for your help.

Ghislain

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

If you're using the PKCE flow, the client secret shouldn't be required, so based on this error it looks like you're not actually in a PKCE flow.

 

Have you modified the OAuthPKCE sample code? I just tried it as is (just plugging in an app key) and it is working for me.

 

Can you confirm you set up the OAuthFlow object as a PKCEOAuthFlow as shown here and that the redirectUri you are passing in to ProcessCodeFlowAsync comes from the same flow started with the same object? (This error would occur if the authorization code you are exchanging wasn't actually retrieved using PKCE.)

View solution in original post

2 Replies 2

Greg-DB
Dropbox Staff
Go to solution

If you're using the PKCE flow, the client secret shouldn't be required, so based on this error it looks like you're not actually in a PKCE flow.

 

Have you modified the OAuthPKCE sample code? I just tried it as is (just plugging in an app key) and it is working for me.

 

Can you confirm you set up the OAuthFlow object as a PKCEOAuthFlow as shown here and that the redirectUri you are passing in to ProcessCodeFlowAsync comes from the same flow started with the same object? (This error would occur if the authorization code you are exchanging wasn't actually retrieved using PKCE.)

Ghislain Sommervogel
Helpful | Level 5
Go to solution

Hello Greg,

Thanks for leading me to the solution. I didn't use the sample code "as is" because I had to adapt a preexisting code. The mistake was to call the GetAuthorizeUri function of DropboxOAuth2Helper instead of PKCEOAuthFlow.

Best regards,

Ghislain

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Ghislain Sommervogel Helpful | Level 5
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?