tv icon indicating copy to clipboard operation
tv copied to clipboard

feat(wip): add YouTube OAuth

Open kaf-lamed-beyt opened this issue 1 year ago • 10 comments

@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

kaf-lamed-beyt avatar Sep 24 '24 10:09 kaf-lamed-beyt

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?

zcesur avatar Sep 25 '24 12:09 zcesur

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 avatar Sep 25 '24 12:09 kaf-lamed-beyt

Here @zcesur

image

kaf-lamed-beyt avatar Sep 25 '24 12:09 kaf-lamed-beyt

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

zcesur avatar Sep 25 '24 12:09 zcesur

Oh okay! I'll do that now.

kaf-lamed-beyt avatar Sep 25 '24 13:09 kaf-lamed-beyt

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 avatar Sep 25 '24 14:09 kaf-lamed-beyt

This might be confusing so let's remove that logic

Alright, I'll have this removed.

kaf-lamed-beyt avatar Sep 27 '24 15:09 kaf-lamed-beyt

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.

kaf-lamed-beyt avatar Sep 27 '24 21:09 kaf-lamed-beyt

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

zcesur avatar Oct 12 '24 09:10 zcesur

Awesome! I'll check the docs out.

kaf-lamed-beyt avatar Oct 12 '24 10:10 kaf-lamed-beyt

@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.

kaf-lamed-beyt avatar Oct 13 '24 16:10 kaf-lamed-beyt

Thanks Caleb!

zcesur avatar Oct 19 '24 17:10 zcesur

Thanks Caleb!

Ayy! Glad I got to work on this. 🫡

kaf-lamed-beyt avatar Oct 19 '24 17:10 kaf-lamed-beyt