Issues with Webview and OAuth

I am new to developing. I have my website, Greasygamer.com, as a webview in Android and iOS apps. When using the browsers, Twitch auth works as intended.

Inside the Webviews, it’s either it doesn’t pass the auth tokens (android) or it says to disable pop up blocker (iOS)

Anyways, I understand the Get() setup, i just dont know how to declare it and call it when the button is clicked. Am i missing something easy?
Here is the GET with the code fille din, where do i put this at? Inside a Func?

GET 'https://id.twitch.tv/oauth2/authorize?response_type=token&client_id=einlh0aqh6snec0a9n6s33c6o4ny30
&redirect_uri=http://localhost
&scope=viewing_activity_read
&state=c3ab8aa609ea11e793ae92361f002671'

Thanks in advance

That would be because it’s supposed to be a redirect/link out to Twitch, not a GET request via curl or similar.

Step 1 of oAuth is redirecting the user to Twitch

1 Like

Thanks for the response. So, instead of GET it would be REDIRECT? and where do I put that at? I am confused on how to code this I guess?

Thank you

I suppose you would open a webview to that URL

So open another webview inside my webview and how would that pass the token to the main webview?

Is there a tutorial I could follow? The Twitch steps here are not helping :frowning:

Implicit flow should just work on the page you are on, assuming you can get a good redirect URL back to your app, if the apps URL is localhost on the app.

As an working example code:

https://barrycarlyon.github.io/twitch_misc/authentication/implicit_auth/

1 Like

Okay man. Thank you for the example!

So i created a seperate javascript file with the code in it. How exactly do I tell it to call it when the button is clicked (the embed chat is controlled by Twitch right? like i can’t change the OnClick function?)

You never mentioned embed chat.

Embedding is covered here

And it handles authentication on it’s own

Even inside of a webview?

Because that works fine in web browsers, but when I create a webview in my iOS or Android Studio app, it doesn’t pass the tokens

I don’t know I don’t have the requistite things to hand to test

What doesn’t pass the tokens? Implicity auth or the embed?

My app is a webview of my website (basically the app is my website, just mobile sized)

Inside of that, the twitch embed doesnt work quite right. When i click the login to chat button, it lets me sign in, but then it redirects to the web version on Twitch, even though i have: &no-mobile-redirect=true" at the end of the twitch link

As i said, it works fine when you go to the website (https://greasygamer.com/streams) but going to that same site inside of my app, it doesn’t login to the app, but goes to the twitch site instead.

hope that helps man

I don’t believe this is a documented thing you can use that I’ve seen anywhere.

Not sure if bug or that the embed’s are not intended to behave/work with login on Mobile webviews.

Might be one for uservoice or the issue tracker

Hmm okay i see. So what is my next step? Do i need to talk to a Twitch dev or Android dev or what? I just wanna get this functionalit working so that it works within my Webview app

It seems like something changed with webviews in march, having done a quick forum search.

I’ve copied the threads to someone to pass around

1 Like

Okay thanks for your help barry. I guess I will just have to wait to hear back lol

Update: I was able to set this up in my webview to redirect Twitch url opening, to my Redirect URI instead. So now it redirects properly and i click the “Authorize button” and it send me back to my site, but when i go back to the chat, it has me do the loop all over again.

  webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url.contains("twitch"))
            {
                webView.loadUrl("https://id.twitch.tv/oauth2/authorize?response_type=token&client_id=9m0ldbpu7ranp6vrwvl501z50xyx2n&redirect_uri=https://greasygamer.com/streams&scope=viewing_activity_read");

            } return false;

        }
    });

Am i missing a step to where it actually holds the token or something?

I just need to know how to take the redirected user and get the token to the validator website so when they go to the stream chat, it works.

Becuase your code gets an oAuth took for your Application. ID’ed by 9m0ldbpu7ranp6vrwvl501z50xyx2n

It doesn’t log you into the embed chat so you can send/receive chat.

Also you requested viewing_activity_read thats the Drops scope, I don’t think you are building drops here

So what would be the fix then? I am confused on this issue, sorry