Skip to content

Save gist to user account when sharing #1114

Open
@heaths

Description

@heaths

Because we can't edit gists created by the Playground, I like to copy the content into my own account and add a comment linking back to the Playground e.g., https://gist.github.com/heaths/9ca334d400763698e0d4c895d495190a. This allows us to make some changes after some discussions and makes it easy to share so colleagues can modify the code in the Playground, try things out, look at different output, etc.

As a simplification of #609 the Playground could [prompt the user for authenticating(https://docs.github.com/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app) with the gist scope and call the gist creation API to create a private gist. The user token wouldn't need to be persisted, thus requiring a backend database, HttpOnly cookies, or the sort. Just keep it and the refresh token in memory.

Additionally, a comment could be added back to the Playground e.g., https://gist.github.com/heaths/9ca334d400763698e0d4c895d495190a?permalink_comment_id=5263599#gistcomment-5263599 (just the first bullet as a single line comment).

By keeping the refresh token in memory, the Playground could also support updates. If the gist already exists it could be updated, using the refresh token as needed. Similarly, if someone navigates to the Playground with an existing gist ID, the update API could be attempted. If it's not their gist the call would fail so there's no need to check authorization ahead of time.

An OAuth App would need to be created for the Playground.

For the UI, I was thinking of a drop-down button like some of the other existing ones. The default would be the existing behavior so no one is surprised, but in a drop-down you could have something like "Save to account".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions