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

Add Snapchat OAuth provider #449

Closed
wants to merge 2 commits into from
Closed

Conversation

nwneisen
Copy link
Contributor

@nwneisen nwneisen commented Apr 17, 2022

What kind of change does this PR introduce?

Adds a feature for Snapchat OAuth. Resolves #436

What is the current behavior?

Snapchat is not available as an OAuth provided

What is the new behavior?

Snapchat can be used as an OAuth provider using the same process as the other OAuth providers found in GoTrue

  • Creating an application on the oauth provider site
  • Generating your own client_id and secret
  • Testing that http://localhost:9999/authorize?provider=snapchat redirects you to the provider sign-in page
  • The callback is handled properly
  • Gotrue redirects to the SITE_URL or one of the URI's specified in the URI_ALLOW_LIST with the access_token, provider_token, expiry and refresh_token as query fragments
  • Writing tests for the new OAuth provider implemented

Additional context

Snapchat OAuth does not use an email. This runs in to the same issue as #214. I put a hack in to get around the checks but I'm sure we want something better.

Copy link
Member

@kangmingtay kangmingtay left a comment

Choose a reason for hiding this comment

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

hey @nwneisen, thanks for the contribution! could you kindly document the steps you took to set up the oauth2 app on snapchat? i've tried testing out your PR locally but am running into this issue on the callback / redirect

image

})
} else {
data.Emails = append(data.Emails, Email{
Email: "Email not supported with Snapchat OAuth",
Copy link
Member

Choose a reason for hiding this comment

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

hmm this is pretty hacky and it wouldn't really work out because we have a unique constraint on the email column

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. It doesn't look like there is a great solution ATM. I took a look at #414 and left a comment. Let me know if there's anything else that could help get it merged.

}

func (g snapchatProvider) GetOAuthToken(code string) (*oauth2.Token, error) {
return g.Exchange(oauth2.NoContext, code)
Copy link
Member

Choose a reason for hiding this comment

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

oauth2.NoContext seems to be deprecated in favour of context.Background() - lets use that instead

@nwneisen
Copy link
Contributor Author

@kangmingtay This is how I have my snapchat configured. Let me know if you need additional info for any section.

  1. Create a developer account on https://kit.snapchat.com/. Setup your organization and a project.
  2. Open the project and click + New Version on the left to create a new version.
  • Fill out any required information
  • Enable the Login Kit section. Enable the Display Name, Bitmoji Avatar, and add a Redirect URI. I just modified my /etc/hosts and did http://localhost:9999/callback.
  1. Open the Setup tab and set the new version as active in the Staging dropdown.
  • Click the add button to generate a Confidential OAuth 2.0 Client ID. Add the Confidential Client ID and Confidential Client Secret to your .env. file.
  • Add your snapchat Username to the Demo Users section
  1. Navigate to `localhost:9999/authorize?provider=snapchat in your browser

@hf
Copy link
Contributor

hf commented Aug 24, 2022

Hey this PR has been outdated for a long while now. I'll close it, but if you still wish to contribute please re-open it or submit a new one!

@hf hf closed this Aug 24, 2022
@nwneisen
Copy link
Contributor Author

Hey this PR has been outdated for a long while now. I'll close it, but if you still wish to contribute please re-open it or submit a new one!

This was waiting for the email constraint to be removed. Otherwise, everything should've been addressed for it.

@hf hf reopened this Aug 24, 2022
@hf
Copy link
Contributor

hf commented Aug 24, 2022

@nwneisen Oh sorry, I may have rushed too much.

@nwneisen nwneisen closed this Apr 3, 2023
@Thedarklord09
Copy link

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.

Add Snapchat as External OAuth Providers
4 participants