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

RFC: Fix go-mastodon authentication flows #196

Merged
merged 2 commits into from
Oct 25, 2024
Merged

Conversation

coolapso
Copy link
Contributor

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 #194 and most likely the potential causes of #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 #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
Copy link
Owner

mattn commented Oct 24, 2024

Oh, cool.

@codecov-commenter
Copy link

codecov-commenter commented Oct 24, 2024

⚠️ 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 ⚠️
examples/public-application/main.go 0.00% 51 Missing ⚠️
examples/user-credentials/main.go 0.00% 25 Missing ⚠️
mastodon.go 72.22% 10 Missing and 5 partials ⚠️

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

❗ 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
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mattn
Copy link
Owner

mattn commented Oct 24, 2024

Sorry, could you please fix confict?

Update authentication flow to be aligned with mastodon documentation
Refactor authetnication to be more explicit and easier to understand
Add working examples for each authentication method
Update Documenation

Deprectaed client methods: Authenticate(), AuthenticateApp(), AuthenticateToken(), authenticate()
New client methods: GetAppAccessToken(), GetUserAccessToken(), getAccessToken()
@coolapso
Copy link
Contributor Author

Sorry, could you please fix confict?

@mattn Done! :)

@mattn
Copy link
Owner

mattn commented Oct 25, 2024

Thank you

@mattn mattn merged commit 213f36e into mattn:master Oct 25, 2024
@marians
Copy link
Contributor

marians commented Nov 7, 2024

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

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
Copy link
Contributor Author

coolapso commented Nov 7, 2024

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

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.

Re-using access token
4 participants