sergiodxa / remix-auth-oauth2

A OAuth2Strategy for Remix Auth
https://sergiodxa.github.io/remix-auth-oauth2/
MIT License
160 stars 63 forks source link

Question about OAuth2Profile typings #41

Closed hallowatcher closed 5 months ago

hallowatcher commented 1 year ago

Hey, I had a question about OAuth2 profiles. Currently in this library, they are typed like this:

image image

This means that any type of profile I pass in must extend from that OAuth2Profile interface, even if it doesn't include all of those properties.

How can I type this to only be what the OAuth API provides?

hallowatcher commented 1 year ago

If you need an example, I made a full custom implementation of an OAuth strategy for osu!.

In the method for returning a profile from the API, I want to return the full API user instead of the one that extends OAuth2Profile, which like mentioned has properties that I will never need.

image

So in this example, I just want to write return await request.json() instead of creating a new object.

sergiodxa commented 1 year ago

From the OAuth2Profile the only required field is the provider, the rest are optional meaning you can add only what you need. But if you need something that the OAuth2Profile uses it would be ideal to return it, for example use displayName for the username.

The reason the OAuth2Profile exists is to allow strategy authors to normalize the data, if you install any OAuth2-based strategy you know the profile has an array of emails for example.

But if you're extending the OAuth2Strategy locally in your project feel free to return anything you need.