h3poteto / megalodon-rs

Fediverse API client library for Rust
Apache License 2.0
113 stars 24 forks source link

missing field `scope` when authorizing agains snac2 mastodon api #258

Open AkkermanD opened 1 week ago

AkkermanD commented 1 week ago

Hello! I'm facing an issue while trying to authorize against the snac2 mastodon api. The fetch_access_token returns an error: missing field scope at line 5 column 1

Snac supports subset of the mastodon's API, but it does not return the scope field, if there were no such field in the request: https://codeberg.org/grunfink/snac2/src/commit/2769e6b1d76b1043f8d8cdb928a95ade48b8ebff/mastoapi.c#L404

Megalodon does not send the scope field: https://docs.rs/megalodon/latest/src/megalodon/mastodon/mastodon.rs.html#135

But it looks like it is Ok for oauth server to not return scope in the response, if it is identical to the scope requested by the client: https://datatracker.ietf.org/doc/html/rfc6749#section-5.1

scope OPTIONAL, if identical to the scope requested by the client; otherwise, REQUIRED.

I'm not sure if it worth to add new SNS for the snac to fix this. Can we make scope field optional in the TokenDataFromServer struct?

h3poteto commented 1 week ago

There is no problem changing scope to an optional field, but it's better to add snac2 as a new SNS.