cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Tell us what you want to see on the Community here!
Close

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: 

Ruby API v2 Client got Internal Server Error after redirected from oauth2.authorize

Highlighted

Ruby API v2 Client got Internal Server Error after redirected from oauth2.authorize

Explorer | Level 3

I deployed my Ruby app in GAE, and browsed it with url: https://xxxxxxxxxxxxxx.appspot.com/.

After directed to https://www.dropbox.com/oauth2/authorize, I click the Allow, the the page was directed to 

https://xxxxxxxxxxxxxx.appspot.com/auth, and only showed: Internal Server Error

 

Part of my code is pasted below:

def authenticator
    # Create dropbox session object and serialize it to the Sinatra session
    authenticator = DropboxApi::Authenticator.new(APP_KEY, APP_SECRET)
end

enable :sessions

get '/' do
    @loggedin = (session[:dropbox] != nil)
    erb :index
end

get '/login' do
    session[:dropbox] = 'init'
    # redirect user to Dropbox auth page
    redirect authenticator.authorize_url :redirect_uri => URL #= dropbox_session.get_authorize_url(URL)
end

get '/auth' do

    redirect 'login' unless session[:dropbox] == 'init'

    auth = authenticator.get_token(params['code'], :redirect_uri => URL)
    token = auth.token

    session[:dropbox] = token
    redirect '/write'
end

 

 

This is the log: 

2020-07-05 11:47:50 default[20200705t193819] https://xxxxxxxxxxxxxx.appspot.com/ -> /login
2020-07-05 11:48:47 default[20200705t193819] "GET /write?code=jezOSqKvFNAAAAAAAAAAT42cxSNkV3SGaY2HhBnt-28 HTTP/1.1" 302
2020-07-05 11:48:47 default[20200705t193819] 112.120.226.172, 169.254.1.1 - - [05/Jul/2020 11:48:47] "GET /write?code=jezOSqKvFNAAAAAAAAAAT42cxSNkV3SGaY2HhBnt-28 HTTP/1.1" 302 - 0.0007
2020-07-05 11:48:47 default[20200705t193819] 127.0.0.1 - - [05/Jul/2020:11:48:47 UTC] "GET /write?code=jezOSqKvFNAAAAAAAAAAT42cxSNkV3SGaY2HhBnt-28 HTTP/1.1" 302 0
2020-07-05 11:48:47 default[20200705t193819] https://xxxxxxxxxxxxxx.appspot.com/ -> /write?code=jezOSqKvFNAAAAAAAAAAT42cxSNkV3SGaY2HhBnt-28
2020-07-05 11:48:48 default[20200705t193819] "GET /auth HTTP/1.1" 500
2020-07-05 11:48:49 default[20200705t193819] OAuth2::Error - invalid_request: "code": must not be empty
2020-07-05 11:48:49 default[20200705t193819] {"error_description": "\"code\": must not be empty", "error": "invalid_request"}:
2020-07-05 11:48:49 default[20200705t193819] /layers/google.ruby.bundle/gems/.bundle/gems/ruby/2.5.0/gems/oauth2-1.3.1/lib/oauth2/client.rb:119:in `request'
2020-07-05 11:48:49 default[20200705t193819] /layers/google.ruby.bundle/gems/.bundle/gems/ruby/2.5.0/gems/oauth2-1.3.1/lib/oauth2/client.rb:146:in `get_token'
2020-07-05 11:48:49 default[20200705t193819] /layers/google.ruby.bundle/gems/.bundle/gems/ruby/2.5.0/gems/oauth2-1.3.1/lib/oauth2/strategy/auth_code.rb:30:in `get_token'
2020-07-05 11:48:49 default[20200705t193819] app.rb:44:in `block in <main>'

1 Reply 1
Highlighted

Re: Ruby API v2 Client got Internal Server Error after redirected from oauth2.authorize

Dropboxer

The '"code": must not be empty' comes from the Dropbox API /oauth2/token endpoint, and indicates that the client did not supply the required "code" parameter. 

 

You'll need to debug your app to see why you're not sending up the expected code value, which seems like it's supposed to be in the 'params['code']' in your case. I can't offer help with Ruby or your web framework itself though.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?