jhudsl / ottrpal

Tools for converting OTTR courses into Leanpub or Coursera courses :otter:
https://jhudatascience.org/ottrpal/
GNU General Public License v3.0
3 stars 1 forks source link

Supplying authorization to get slide notes for ottrpal #118

Closed cansavvy closed 10 months ago

cansavvy commented 11 months ago

Purpose/implementation Section

What changes are being implemented in this Pull Request?

This was something we pair coded on. Basically if credentials aren't supplied we want to use a dummy credential to grab slides that are public anyway.

This code should do that with some encryption steps as well.

This is a PR based off the conversation here: https://github.com/jhudsl/ottrpal/pull/116#issuecomment-1661231230

howardbaek commented 10 months ago

It seems like auth_from_secret() is a function that uses the "secrets" that we provided to the ottrpal R package to obtain a token. If so, should we just get rid of all the function arguments (access_token and refresh_token) so that when we run auth_from_secret(), we run this chunk no matter what:

decrypted <- openssl::aes_cbc_decrypt(
      readRDS(encrypt_creds_user_path()),
      key = readRDS(key_encrypt_creds_path())
)

and we create decrypted. When I supply a value to access_token and refresh_token, then the above code chunk doesn't run since its inside an if statement, and the following code chunk throws an error since it doesn't know what decrypted is:

  credentials <- list(
    access_token =  unserialize(decrypted)[[1]]$access_token,
    expires_in = 3599L,
    refresh_token = unserialize(decrypted)[[1]]$refresh_token,
    scope = scopes_list,
    token_type = "Bearer"
  )
howardbaek commented 10 months ago

@cansavvy Looks good. Merged.