Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

feat(sg): one-time oauth login to persist user email for analytics#63603

Merged
burmudar merged 6 commits into
mainfrom
nsc/sg-oauth
Jul 9, 2024
Merged

feat(sg): one-time oauth login to persist user email for analytics#63603
burmudar merged 6 commits into
mainfrom
nsc/sg-oauth

Conversation

@Strum355

@Strum355 Strum355 commented Jul 2, 2024

Copy link
Copy Markdown
Contributor

Uses OAuth flow to fetch user's email as a one-time action, persisting it in ~/.sourcegraph/whoami.json. Flow is only re-attempted if that file doesnt exist (failed to read) or if the email is empty.

Code yoinked and adapted from @nelsonjr 's code for sg rfc 🙏

image

Test plan

Tested locally, see screenshots above

Changelog

@Strum355 Strum355 added the sg sg, the Sourcegraph developer command label Jul 2, 2024
@Strum355 Strum355 requested a review from a team July 2, 2024 18:01
@Strum355 Strum355 self-assigned this Jul 2, 2024
@cla-bot cla-bot Bot added the cla-signed label Jul 2, 2024
@Strum355 Strum355 force-pushed the nsc/sg-oauth branch 3 times, most recently from 71fcfb6 to d10f5f5 Compare July 3, 2024 11:15

@jhchabran jhchabran left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good stuff, good catch thinking about a misformated json and handling it from the get go 🙏

Made a suggestion for the notice itself, which is a very important bit (only reason for which this isn't approved yet).

Comment thread dev/sg/internal/analytics/oauth.go Outdated
Comment thread dev/sg/internal/analytics/oauth.go
@jhchabran

jhchabran commented Jul 3, 2024

Copy link
Copy Markdown
Contributor

@Strum355 I'll make a PR to print a warning that when in dev, a few things are disabled, I scratched my head for a minute before understanding what was going on.

EDIT: https://github.com/sourcegraph/sourcegraph/pull/63612

Comment thread dev/sg/main.go Outdated
@burmudar burmudar self-assigned this Jul 9, 2024
@burmudar burmudar requested a review from jhchabran July 9, 2024 09:33
@burmudar burmudar merged commit d9dff11 into main Jul 9, 2024
@burmudar burmudar deleted the nsc/sg-oauth branch July 9, 2024 10:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed sg sg, the Sourcegraph developer command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants