mattn / go-mastodon

mastodon client for golang
MIT License
604 stars 88 forks source link

RFC: Fix go-mastodon authentication flows #196

Closed coolapso closed 1 month ago

coolapso commented 1 month ago

at this point go-mastodon authentication is quite confusing and not aligned with the mastodon documentation, causing confusion and misunderstandings about the package usage. Existing methods are not descriptive of what exactly is happening thus making it hard to understand how credentials should be used in general, specially around the exchange between an authorization code and an access token.

This PR aims to fix https://github.com/mattn/go-mastodon/issues/194 and most likely the potential causes of https://github.com/mattn/go-mastodon/issues/154

And the purposed solution marks the existing methods as DEPRECATED and creates new ones thus avoiding breaking changes with previous versions of this package.

in the issue https://github.com/mattn/go-mastodon/issues/194 I've mentioned about returning the value of the access token, however for consistency I have decided to not do it, and opted to keep a similar approach to the original approach and instead documented how users can export the credentials for using them at a later stage.

This pr also updates the package documentation by adding a directory with different working examples. Code snippets were removed from the README and instead added links to mastodon documentation and to the working examples so users can try them for themselves in a quicker way.

Any comments or suggestions are highly appreciated.

mattn commented 1 month ago

Oh, cool.

codecov-commenter commented 1 month ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 18.66029% with 170 lines in your changes missing coverage. Please review.

Project coverage is 78.29%. Comparing base (9faaa4f) to head (a06b707). Report is 26 commits behind head on master.

Files with missing lines Patch % Lines
examples/user-oauth-authorization/main.go 0.00% 79 Missing :warning:
examples/public-application/main.go 0.00% 51 Missing :warning:
examples/user-credentials/main.go 0.00% 25 Missing :warning:
mastodon.go 72.22% 10 Missing and 5 partials :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

:exclamation: There is a different number of reports uploaded between BASE (9faaa4f) and HEAD (a06b707). Click for more details.

HEAD has 7 uploads less than BASE | Flag | BASE (9faaa4f) | HEAD (a06b707) | |------|------|------| ||12|5|
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #196 +/- ## ========================================== - Coverage 87.51% 78.29% -9.23% ========================================== Files 15 19 +4 Lines 1354 1617 +263 ========================================== + Hits 1185 1266 +81 - Misses 125 298 +173 - Partials 44 53 +9 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

mattn commented 1 month ago

Sorry, could you please fix confict?

coolapso commented 1 month ago

Sorry, could you please fix confict?

@mattn Done! :)

mattn commented 1 month ago

Thank you

marians commented 2 weeks ago

Looks like the latest release v0.0.9 has been tagged before this got merged.

https://github.com/mattn/go-mastodon/compare/v0.0.9...HEAD

Am I right assuming that the examples in the repo now reflect a state that is incompatible with the latest version v0.0.9? If yes, this could lead to more confusion. Anything speaking against a v0.0.10 release?

coolapso commented 2 weeks ago

yeah something weird happend .. but I think if you do go get -u it will grab the latest commit .. or at least it looks like it did so for me: https://github.com/coolapso/megophone/blob/main/go.mod#L8