External Authentication for Android?

Hi all,

I would like to implement External Authentication for Android apps (Written in Kotlin).

I refer to two documentation links:

  1. https://github.com/home-assistant/developers.home-assistant/blob/master/docs/frontend_external_auth.md
  2. https://developers.home-assistant.io/docs/en/frontend_external_auth.html

Based on this two links, I should add ?external_auth=1 to my HA url. So my url will become http://IP:8123/?external_auth=1 .

After run, it become like screenshot below:

So, just to confirm, I need to execute all the following commands in my Android app so that could successfully login HA using External Authentication method?

window.externalApp.getExternalAuth({
  callback: 'externalAuthSetToken'
});

// To be called by external app
window.externalAuthSetToken(true, {
  "access_token": "qwere",
  "expires_in": 1800
});

Or do I miss out somethings else?

Thanks.

I can’t help you out with Android specifics (yet :smile:) but you might want to take a look at the iOS code (WebViewController.swift) to see how we are handling it. Your code generally looks correct as-is.

1 Like