Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Don't merge yet] Integrate Zenodo API for Plan PDF uploads #2132

Closed
wants to merge 8 commits into from

Conversation

Bodacious
Copy link
Contributor

Changes proposed in this PR:

  • Add support for users to connect their account to Zenodo API
  • Add support for users to upload a DMP to Zenodo as a PDF

Please note: to test this, you'll need to do the following:

  1. Add a HOST env variable (for OAuth 2.0 redirects). This should be set to whatever master domain the app is running on (will be 'localhost:3000' in development).
  2. Create an application on the Zenodo sandbox and Zenodo live environments
  3. Obtain.a CLIENT_ID and CLIENT_SECRET for the applications, and store these as env variables.

Go to the "Share" tab for a given Plan and click the Zenodo button at the foot of the page

@Bodacious Bodacious requested a review from xsrust May 9, 2019 18:15
@Bodacious Bodacious changed the title Integrate Zenodo API for Plan PDF uploads [Don't merge yet] Integrate Zenodo API for Plan PDF uploads May 10, 2019
Copy link
Contributor

@briri briri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall @Bodacious. Left a comment about one of the user updates.

I'm noticing a lot of use of ENV variables. This approach makes assumptions about how people deploy and configure their installations. It would be preferable to assign these values to the Rails.configuration somewhere on initialization perhaps rather than referencing them directly in the application code. Something like:

Rails.application.configure do
  config.oauth2['zenodo']['client_id'] = ENV["ZENODO_CLIENT_ID"] || config.branding['oauth2']['zenodo']['client_id']
end

And then in the code:

OAuth2::Client.new(
  Rails.config.oauth2[provider]['client_id'],
  Rails.config.oauth2[provider]['client_secret'],
  site: provider.classify.constantize.const_get("BASE"),
  logger: Logger.new(Rails.root.join("log", "#{provider}.log"), 'weekly')
)

@@ -39,6 +39,18 @@ def plan_attribution(attribution)
"<strong>#{prefix}</strong> #{attribution.join(', ')}"
end

def download_plan_page_title(plan, phase, hash)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for moving these over. makes more sense for them to be in the exports_helper

client = client_for_oauth2_provider(params[:provider])
@token = client.auth_code.get_token(params[:code],
redirect_uri: REDIRECT_URI % params)
current_user.update!(zenodo_access_token: @token.token)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zenodo_access_token is very specific while the rest of the class is generic. Maybe something like current_user.update!("#{provider}_access_token": @token.token) instead

@@ -0,0 +1,2 @@
<h1>Arpha::Plans#show</h1>
<p>Find me in app/views/arpha/plans/show.html.erb</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? Not sure what this is doing

NOTE: `access_token` param has been hidden from logger. This isn't strictly necessary,
since that param isn't currently being logged in production mode. But I've kept it that
way to offer a bit more security in case someone changes the logger level later.
Removed this for debugging and forgot to reinstate it. Thanks Brakeman!
@briri
Copy link
Contributor

briri commented Sep 6, 2019

Ignore my prior comments with regard to the ENV variables. @xsrust introduced me to dotenv-rails which will be a part of the codebase going forward.

@magdalenadrafiova
Copy link

@xsrust @briri just adding comment here that this is the work we started on Zenodo, we discussed with @mariapraetzellis and @pherterich yesterday as we planned this for autumn 2020 in our Roadmap

@johnpinto1
Copy link
Contributor

@martaribeiro & @gjacob24 I guess we close this and keepthe branch as suggested by @briri

@johnpinto1 johnpinto1 closed this Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants