Conversation
|
@nelsonic can I request a review? It's just a small addition of scope info to allow for conditional handling |
nelsonic
left a comment
There was a problem hiding this comment.
Hi @prplmg, 👋
Thanks very much for opening this PR to add the scope to the access_token;
seems like a useful addition. 👍
Very happy to merge this as it adds a useful feature.
But for future reference: avoid changing code that doesn't strictly need to be changed. It makes it much easier for module authors/maintainers to review & merge your code. In the case of set_user_details/2 having the return value changed will make this update a "breaking change" for someone using that function in the existing way so is unlikely to be merged.
Thanks again for contributing and happy Elixir-ing 🎉
nelsonic
left a comment
There was a problem hiding this comment.
As expected the tests fail: https://github.com/dwyl/elixir-auth-github/actions/runs/4930569458/jobs/8842364320?pr=81

this is because of the breaking change to set_user_details/2 which cascades through ...
We need to revert that change and then this PR can be merged. 👌
|
@prplmg if you can revert the change made to |
|
@prplmg thanks for opening this PR. elixir-auth-github/lib/elixir_auth_github.ex Lines 46 to 54 in a851e1e Is there an edge case where the scope is unkown to the person using this package? I'm not sure I understand why we need to add the scope information to the Edit: After reading the Github documentation, https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#2-users-are-redirected-back-to-your-site-by-github So the reply contains |
added scope to mock requests
Just pushed some changes that reverts the changes to [ |
Great question! We're developing an app where we can login via github, but not necessarity grant |
Codecov Report
@@ Coverage Diff @@
## main #81 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 32 34 +2
=========================================
+ Hits 32 34 +2
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
@nelsonic reverted the breaking changes, updated the tests, and fixed the coverage issue, I think it's good to go! |
Ok I think I can see the use case, you're adding more scopes at a later stage. |
|
|
||
| defp check_authenticated(error), do: {:error, error} | ||
|
|
||
| defp set_scope({:ok, user_details}, scope) do |
There was a problem hiding this comment.
I would actually make this a def instead of defp so that it could be tested independently
to make sure that it degrades gracefully. e.g. if scope is nil does it still work?
Looks like you're handling the case of _scope below but it's not immediately obvious. 💭
There was a problem hiding this comment.
it's not possible for just scope to be nil, as that would mean access_token is also nil and check_authenticated/1 would fail, with set_scope/2 forwarding the error.
|
Package published to https://hex.pm/packages/elixir_auth_github/1.6.4 📦 🚀 |
How should I add it to the doc? I added it to the return object example, but I understand if it's a bit vague to not explain where it comes from. However, I could not find a more suitable place to mention it. |

Adds
scopekey to theElixirAuthGithub.github_authreturn object