algora-io / tv

Open source Twitch for developers
https://algora.tv
Other
1.07k stars 67 forks source link

feat(wip): add YouTube OAuth #107

Closed kaf-lamed-beyt closed 1 month ago

kaf-lamed-beyt commented 2 months ago

@zcesur, I've been able to setup the OAuth flow with Ueberauth, but I'm having a blocker when trying to persist the state, via the callback.

Kindly take a look and let me know where I might be doing something wrong.

Settings UI on Algora

Screenshot from 2024-09-24 11-22-12

OAuth screen google-oauth

/claim #104

zcesur commented 1 month ago

Looks good!

I'm having a blocker when trying to persist the state, via the callback

Are there any errors in your logs when the callback is invoked?

kaf-lamed-beyt commented 1 month ago

Yeah, there were. Something around the function create_or_update_youtube_identity not being defined. Hold on. I'll share a screenshot.

kaf-lamed-beyt commented 1 month ago

Here @zcesur

image

zcesur commented 1 month ago

We need to define the changeset we're using in the callback, see lib/algora/accounts/identity.ex

kaf-lamed-beyt commented 1 month ago

Oh okay! I'll do that now.

kaf-lamed-beyt commented 1 month ago

Had a couple of issues with retrieving the provider value. Apparently, Ueberauth returns the value as an atom. I had to convert it so it matches the "identities" schema.

Clicking on the button when an account is connected automatically disconnects that identity. Is this a good thing to do?

I've got a slight issue with the placement of the button though. Although, I added a margin, it did not align the button correctly. PS: the other button doesn't show up when it is connected. Screenshot from 2024-09-25 15-05-02

kaf-lamed-beyt commented 1 month ago

This might be confusing so let's remove that logic

Alright, I'll have this removed.

kaf-lamed-beyt commented 1 month ago

So, a little update here @zcesur.

Yes. the scopes were not exactly correct. So I've updated it, and now the OAuth screen shows this properly. oauth-consent-screen.

The refresh_token property returns a value now — instead of nil.

I added a dummy function to update the Google token... basically just followed your approach in /lib/algora/accounts.ex.But I realized that I might have to implement something similar to the one here for Restream 👇🏼

https://github.com/algora-io/tv/blob/677d6c74b86d853200aea1dfc7624b4a8f74f823/lib/algora/restream.ex#L66-L92

Would that be something I need to get into? If yes, perhaps, a little guidance, thanks.

zcesur commented 1 month ago

The refresh_token property returns a value now — instead of nil.

Perfect

But I realized that I might have to implement something similar to the one here for Restream

Yeah we need this for offline access (viewing analytics, uploading clips etc). It's pretty much the same as refreshing Restream tokens, check out the docs here

kaf-lamed-beyt commented 1 month ago

Awesome! I'll check the docs out.

kaf-lamed-beyt commented 1 month ago

@zcesur, i added the refresh_token function now. When you can, please a look and let me know if I'm on the right path.

zcesur commented 1 month ago

Thanks Caleb!

kaf-lamed-beyt commented 1 month ago

Thanks Caleb!

Ayy! Glad I got to work on this. 🫡