<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Ruby API v2 Client got Internal Server Error after redirected from oauth2.authorize in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Ruby-API-v2-Client-got-Internal-Server-Error-after-redirected/m-p/434797#M22972</link>
    <description>&lt;P&gt;I deployed my Ruby app in GAE, and browsed it with url:&amp;nbsp;&lt;A href="https://xxxxxxxxxxxxxx.appspot.com/" target="_blank" rel="noopener"&gt;https://xxxxxxxxxxxxxx.appspot.com/&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;After directed to&amp;nbsp;&lt;A href="https://www.dropbox.com/oauth2/authorize" target="_blank" rel="noopener"&gt;https://www.dropbox.com/oauth2/authorize&lt;/A&gt;, I click the Allow, the the page was directed to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://xxxxxxxxxxxxxx.appspot.com/auth" target="_blank" rel="noopener"&gt;https://xxxxxxxxxxxxxx.appspot.com/auth&lt;/A&gt;, and only showed:&amp;nbsp;&lt;SPAN&gt;Internal Server Error&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Part of my code is pasted below:&lt;/P&gt;&lt;PRE&gt;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 =&amp;gt; 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 =&amp;gt; URL)
    token = auth.token

    session[:dropbox] = token
    redirect '/write'
end&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the log:&amp;nbsp;&lt;/P&gt;&lt;P&gt;2020-07-05 11:47:50 default[20200705t193819] &lt;A href="https://xxxxxxxxxxxxxx.appspot.com/" target="_blank" rel="noopener"&gt;https://xxxxxxxxxxxxxx.appspot.com/&lt;/A&gt; -&amp;gt; /login&lt;BR /&gt;2020-07-05 11:48:47 default[20200705t193819] "GET /write?code=jezOSqKvFNAAAAAAAAAAT42cxSNkV3SGaY2HhBnt-28 HTTP/1.1" 302&lt;BR /&gt;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&lt;BR /&gt;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&lt;BR /&gt;2020-07-05 11:48:47 default[20200705t193819] &lt;A href="https://xxxxxxxxxxxxxx.appspot.com/" target="_blank" rel="noopener"&gt;https://xxxxxxxxxxxxxx.appspot.com/&lt;/A&gt; -&amp;gt; /write?code=jezOSqKvFNAAAAAAAAAAT42cxSNkV3SGaY2HhBnt-28&lt;BR /&gt;2020-07-05 11:48:48 default[20200705t193819] "GET /auth HTTP/1.1" 500&lt;BR /&gt;2020-07-05 11:48:49 default[20200705t193819] OAuth2::Error - invalid_request: "code": must not be empty&lt;BR /&gt;2020-07-05 11:48:49 default[20200705t193819] {"error_description": "\"code\": must not be empty", "error": "invalid_request"}:&lt;BR /&gt;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'&lt;BR /&gt;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'&lt;BR /&gt;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'&lt;BR /&gt;2020-07-05 11:48:49 default[20200705t193819] app.rb:44:in `block in &amp;lt;main&amp;gt;'&lt;/P&gt;</description>
    <pubDate>Sun, 05 Jul 2020 12:04:50 GMT</pubDate>
    <dc:creator>Togor</dc:creator>
    <dc:date>2020-07-05T12:04:50Z</dc:date>
    <item>
      <title>Ruby API v2 Client got Internal Server Error after redirected from oauth2.authorize</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Ruby-API-v2-Client-got-Internal-Server-Error-after-redirected/m-p/434797#M22972</link>
      <description>&lt;P&gt;I deployed my Ruby app in GAE, and browsed it with url:&amp;nbsp;&lt;A href="https://xxxxxxxxxxxxxx.appspot.com/" target="_blank" rel="noopener"&gt;https://xxxxxxxxxxxxxx.appspot.com/&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;After directed to&amp;nbsp;&lt;A href="https://www.dropbox.com/oauth2/authorize" target="_blank" rel="noopener"&gt;https://www.dropbox.com/oauth2/authorize&lt;/A&gt;, I click the Allow, the the page was directed to&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://xxxxxxxxxxxxxx.appspot.com/auth" target="_blank" rel="noopener"&gt;https://xxxxxxxxxxxxxx.appspot.com/auth&lt;/A&gt;, and only showed:&amp;nbsp;&lt;SPAN&gt;Internal Server Error&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Part of my code is pasted below:&lt;/P&gt;&lt;PRE&gt;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 =&amp;gt; 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 =&amp;gt; URL)
    token = auth.token

    session[:dropbox] = token
    redirect '/write'
end&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the log:&amp;nbsp;&lt;/P&gt;&lt;P&gt;2020-07-05 11:47:50 default[20200705t193819] &lt;A href="https://xxxxxxxxxxxxxx.appspot.com/" target="_blank" rel="noopener"&gt;https://xxxxxxxxxxxxxx.appspot.com/&lt;/A&gt; -&amp;gt; /login&lt;BR /&gt;2020-07-05 11:48:47 default[20200705t193819] "GET /write?code=jezOSqKvFNAAAAAAAAAAT42cxSNkV3SGaY2HhBnt-28 HTTP/1.1" 302&lt;BR /&gt;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&lt;BR /&gt;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&lt;BR /&gt;2020-07-05 11:48:47 default[20200705t193819] &lt;A href="https://xxxxxxxxxxxxxx.appspot.com/" target="_blank" rel="noopener"&gt;https://xxxxxxxxxxxxxx.appspot.com/&lt;/A&gt; -&amp;gt; /write?code=jezOSqKvFNAAAAAAAAAAT42cxSNkV3SGaY2HhBnt-28&lt;BR /&gt;2020-07-05 11:48:48 default[20200705t193819] "GET /auth HTTP/1.1" 500&lt;BR /&gt;2020-07-05 11:48:49 default[20200705t193819] OAuth2::Error - invalid_request: "code": must not be empty&lt;BR /&gt;2020-07-05 11:48:49 default[20200705t193819] {"error_description": "\"code\": must not be empty", "error": "invalid_request"}:&lt;BR /&gt;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'&lt;BR /&gt;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'&lt;BR /&gt;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'&lt;BR /&gt;2020-07-05 11:48:49 default[20200705t193819] app.rb:44:in `block in &amp;lt;main&amp;gt;'&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jul 2020 12:04:50 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Ruby-API-v2-Client-got-Internal-Server-Error-after-redirected/m-p/434797#M22972</guid>
      <dc:creator>Togor</dc:creator>
      <dc:date>2020-07-05T12:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: Ruby API v2 Client got Internal Server Error after redirected from oauth2.authorize</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Ruby-API-v2-Client-got-Internal-Server-Error-after-redirected/m-p/435191#M22977</link>
      <description>&lt;P&gt;The '"code": must not be empty' comes from &lt;A href="https://www.dropbox.com/developers/documentation/http/documentation#oauth2-token" target="_self"&gt;the&amp;nbsp;Dropbox API&amp;nbsp;/oauth2/token endpoint&lt;/A&gt;, and indicates that the client did not supply the required "code" parameter.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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&amp;nbsp;in the 'params['code']' in your case. I can't offer help with Ruby or your web framework itself though.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jul 2020 17:25:21 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Ruby-API-v2-Client-got-Internal-Server-Error-after-redirected/m-p/435191#M22977</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2020-07-06T17:25:21Z</dc:date>
    </item>
  </channel>
</rss>

