2017-10-06 26 views
0

我在Dropbox上創建了一個應用程序,我正在遵循https://github.com/robin850/carrierwave-dropbox步驟,但無法獲取訪問令牌。 雖然我提供了正確的密鑰和應用程序的祕密,但它無法獲取允許我的應用程序的鏈接,但它有400個不好的請求。carrierwave-dropbox授權

以下是錯誤和我創建的Ruby-on-Rails應用程序:

rake aborted! 
DropboxAuthError: Error getting request token. Is your app key and secret correctly set? Server returned 400: Bad Request. 
/var/lib/gems/2.3.0/gems/dropbox-sdk-1.6.5/lib/dropbox_sdk.rb:277:in `get_token' 
/var/lib/gems/2.3.0/gems/dropbox-sdk-1.6.5/lib/dropbox_sdk.rb:293:in `get_request_token' 
/var/lib/gems/2.3.0/gems/dropbox-sdk-1.6.5/lib/dropbox_sdk.rb:299:in `get_authorize_url' 
/var/lib/gems/2.3.0/gems/carrierwave-dropbox-1.2.1/lib/carrierwave/dropbox/rake.rb:13:in `authorize' 
/var/lib/gems/2.3.0/gems/carrierwave-dropbox-1.2.1/lib/carrierwave/dropbox/authorize.rake:11:in `block (2 levels) in <top (required)>' 
/var/lib/gems/2.3.0/gems/rake-12.1.0/exe/rake:27:in `<top (required)>' 
Tasks: TOP => dropbox:authorize 
(See full trace by running task with --trace) 

回答

0

你有沒有配置carrierwave

CarrierWave.configure do |config| 
    config.dropbox_app_key = ENV["APP_KEY"] 
    config.dropbox_app_secret = ENV["APP_SECRET"] 
    config.dropbox_access_token = ENV["ACCESS_TOKEN"] 
    config.dropbox_access_token_secret = ENV["ACCESS_TOKEN_SECRET"] 
    config.dropbox_user_id = ENV["USER_ID"] 
    config.dropbox_access_type = "dropbox" 
end 
+0

nope,因爲第一步是授權它 –

+0

我假設你已經創建了一個Dropbox應用程序,並把正確的應用程序密鑰和祕密 –

+0

是的我已經把正確的密鑰和應用程序的祕密,但它不給我的鏈接允許我的應用程序 –

0

下面是一個例子希望它可以工作:

1-創建文件config/config.yml並在此處提供您的密鑰:

default: &default 

development: 
    <<: *default 
    app_key: "your_app_key" 

production: &production 
    <<: *default 
    app_key: "your_app_key" 

staging: &staging 
    <<: *default 
    app_key: "your_app_key" 

2 - 在environment.rb文件

# Load the Rails application. 
require_relative 'application' 
APP_CONFIG = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env] 
# Initialize the Rails application. 
Rails.application.initialize! 

3 - 那麼您可以在使用carrierwave.rb文件

CarrierWave.configure do |config| 
    config.dropbox_app_key = APP_CONFIG['app_key'] 
//and your another configuration so on... 
    } 
end 

,如果你有正確的API密鑰的許可,則它應該工作。謝謝

+0

不,我仍然無法讓它工作 –