rinja-rs / play-rinja

Rinja Playground | Online Preview
https://rinja-rs.github.io/play-rinja/
Apache License 2.0
1 stars 0 forks source link

Add a "share code" button #9

Closed GuillaumeGomez closed 3 weeks ago

GuillaumeGomez commented 3 weeks ago

I've been looking into this and I'm not sure how to do it. We could compress both source codes and generate URL parameters in base64 I suppose. Do you have a better idea maybe @Kijewski ?

Kijewski commented 3 weeks ago

It should be possible to register an Oauth app, so we can write Gists for the user (once they allow it). I looked into it and I find Oauth massively complicated, but maybe I'm just stupid. :)

GuillaumeGomez commented 3 weeks ago

I wrote an OAuth2 implementation 7 years ago in an afternoon. It's actually super simple with the right explanations. You just need to find the right explanation. In short (well, actually it's literally just that):

  1. You ask the website an authorization token (that's where the user logs in and say if they want to give you access)
  2. You use the authorization token to ask the website an access token.
  3. You then query the information you want using the access token.

I have a small implementation in python here (well, it starts from this function, but I'll let you take a look if you're interested).

Anyway, I don't think storing content into gist or anywhere is a good idea here. Compression then base64 in URL should be enough I think. ^^'

Kijewski commented 3 weeks ago

Oauth itself is OK if you're actually using it on server-side, but in here I would have liked to keep everything on the client-side, so the browser would get the bearer-token, and talk with github, without any middle-man.

GuillaumeGomez commented 3 weeks ago

That's one more argument in favor to not use oauth or any external service. ;)

Kijewski commented 3 weeks ago

Implemented in #11.