Twitch login/signup for android

Hi,

I am trying to implement twitch login/signup for my android app. I am following OAuth Implicit Code Flow. In the response I am getting html which I am displaying in a webview.

I am getting the error “ERROR for site owner: Invalid domain for site key” inside the captcha box. Please help out in fixing this.

Thanks

Sounds like you are GETing and showing the Twitch Login page instead of redirecting the user to Twitch?

The following:

GET https://id.twitch.tv/oauth2/authorize
    ?client_id=<your client ID>
    &redirect_uri=<your registered redirect URI>
    &response_type=<type>
    &scope=<space-separated list of scopes>

Should read:

REDIRECT THE USER TO https://id.twitch.tv/oauth2/authorize
    ?client_id=<your client ID>
    &redirect_uri=<your registered redirect URI>
    &response_type=<type>
    &scope=<space-separated list of scopes>

Yes I am getting the response and then displaying the response in a webview. So you mean I should just load that url in an android webview?

Correct

If I just load the url in the webview how will I get the access token? As far as I understand is that when a user gives permission the user is redirected to a redirect url that we provide and in that redirect url we get the access token. So the webview just loads the redirect uri.

If you are using implicit auth you can extract the token from the redirecturl:

https://<your registered redirect URI>#access_token=<an access token>

As documented:

Yes I am being redirected to the url as expected. What I don’t understand is that if I don’t have my own server, how do I extract that access token and save it? I mean I am in a webview so I tried to solve this using deep linking but it is not opening the activity when redirected. Please help me out on this I am stuck here.

This might help

I’m not a Android developer so I don’t have any experience to suggest what to do

Thanks for helping me out but I was able to solve it by using shouldOverrideUrlLoading method for the webview.

This method gets called whenever any redirect happens.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.