Oauth flow not triggered on device

Former Member
Former Member

Hello. 

I've been developing a watch face that uses background services (thanks for the great support on this forum) and triggers an oauth flow. Everything works perfectly on the simulator: the first time the watch face is opened the background service triggers the oauth flow. However this never happens on the real device (Fenix 5). I tried to uninstall and then install it again but the problem persists. 

Any guidance is welcome. 

  • Enable logging on the device by adding an empty *.txt file in the LOGS folder. File name mist match that of the prg.

    Then you can narrow down the search and see what happens or not on the device.

  • Former Member
    Former Member in reply to HermoT

    Thanks, I'll do that 

  • Former Member
    Former Member in reply to HermoT

    Got them. This is the expected log output (from emulator):

    Background: App init
    Background: App start
    Background: Someone asked for a service delegate
    Background: Background initialize
    App init
    App start
    Someone requested view

    This is the actual log output on the device:

    App init
    App start
    Someone requested view

    The logs are new, so I know the code is up to date, but for some reason the background process is not activated.

    I have the permissions added, so what else can I do?

  • Former Member
    Former Member in reply to Former Member

    Seems that I was running an old version of the code on the simulator. Now that I "restarted" it the same problem that I have on the device happens on the simulator.

    For some reason I came to the wrong conclusion that, if there is a background class and a getServiceDelegate method the background process will start automatically, which is wrong.

    I'll try to improve the code.

  • Former Member
    Former Member in reply to Former Member

    I noticed that, once a BG process is running on the simulator it will be kept running. That's why I got the impression that any BG process will start automatically, because in my case, the previously running service was still running.

    I'm also learning that, the only reliable entry point for a BG service is the registerForTemporalEvent and the onTemporalEvent methods. All the other stuff is not reliable.

  • Former Member
    Former Member in reply to HermoT

    Finally I get the BG process running by just scheduling the BG process to run. Now the mobile app is crashing when the oauth flow is triggered. Nice! 

  • Former Member
    Former Member in reply to Former Member

    O my God, this is a never-ending nightmare!

    I finally get a flow that seems to work on the device and does not crashes the app. Good! What I got then?? A google error, yes so nice...

    error: disallowed_useragent
    
    Google can't sign you in safely inside this app. 
    You can use google sign-in by visiting this app's website in a browser like safari or chrome

    This obviously does not happen on the simulator. Is there any workaround for this? I can even set a web-service to overwrite the user-agent if that is possible, but seems that this needs to be fixed on connectiq-app side.

  • I seem to recall that this was something that google put in place a while back for security reasons, and there's really no work around, and a few people took down their apps as a result.

  • Former Member
    Former Member in reply to jim_m_58

    If whit a while back you mean more than 2 years ago then yes, you're right.

    I just created a bug report. I really think this is a problem that discourages innovation on garmin apps. Google is one of the main oauth providers and almost all android users use their services. If garmin wants to increase their market and target audience this is a must have.

    It is doable, other apps do it.

  • What other CIQ apps do it?  If I recall, google restricted it to only browsers. (that's also what it says in the error message.)

    I know of a CIQ app that was taken down when google made this change, as the app would no longer work.