venveo / craft-oauthclient

A free to use OAuth 2.0 Client helper for Craft 3 developers
MIT License
9 stars 3 forks source link

Adds the original response as something passed along to token events #26

Closed kennethormandy closed 4 years ago

kennethormandy commented 4 years ago

In the integration I’m making, I found there was extra information from Stripe I needed to save from the original token response.

This adds that original token as response, so it’s accessible via events.

If you’d prefer, I could add a new EVENT_BEFORE_TOKEN_RESPONSE_MODIFIED event or similar instead, before the token is passed to TokenModel::fromLeagueToken()

Or, open to other suggestions if this is already possible to work around and I’m missing something. Thanks!

Mosnar commented 4 years ago

Hey thanks for the PR! This is interesting... I'm hesitant to save the entire token model, but I definitely see the need for it in this case. Let's think about this for a little bit. Eventually, I'd like to add support for public user registrations via OAuth and I worry that saving raw responses in a non-normalized format in bulk could put us in a corner.

Are you trying to store this information: https://stripe.com/docs/connect/oauth-reference#post-token-response

Or do you just need to access it prior to the token being saved?

Here are my ideas:

Let me know if you have any preference or comments on any of these implementations.

kennethormandy commented 4 years ago

Are you trying to store this information: https://stripe.com/docs/connect/oauth-reference#post-token-response

Yes that’s correct, I’m saving the stripe_user_id, but might also need access to livemode too.

I think any of the options would work for me, my preference would probably be one of the first two as well. Right now I’m storing it independently in another field, so I don’t need the whole request stored indefinitely.

Mosnar commented 4 years ago

Just released 2.1.3 that should address this!