Hapi: Bell: question/example for native mobile app login

Created on 18 Jan 2021  ·  2Comments  ·  Source: hapijs/hapi

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): no

Context

  • node version: 12
  • module version: 12
  • environment (e.g. node, browser, native): native mobile app (react native)
  • used with (e.g. hapi application, another framework, standalone, ...): hapi, hapi bell
  • any other relevant information:

How can we help?

Hi hapi community,

Within PlantNet project, we are planning to include Google/Apple/Facebook login into our mobile apps. Bell is setup and works in like 20 line of codes for the web app, based on redirect.
The issue appear when we want to integrate native apps login flow. In those case, we cannot use a http redirect or a webview to ask the user credentials. What we want is using native sdk for signing in (quick demo there. The usual method I've seen is to get the tokenId from Google on the client and sending it to the API for verification and standard login/signup process.

What would be your implementation recommendation for this use case?
Is there any examples that we can look into?

Many thanks

support

Most helpful comment

I took a quick look at the documentation for the server-side here: https://developers.google.com/identity/sign-in/android/offline-access. It seems as though the client will obtain an auth token from Google, and if it sends that token to your API then your API will be able to obtain the user's information from Google. I think you will need to create a route to accept this auth code and reach out to Google to turn it into profile information.

I don't believe that bell or any official hapi plugin will do this for you, however bell's google provider configuration should help! You will post to the token endpoint defined here, and you can use the profile mapping logic defined there too: https://github.com/hapijs/bell/blob/master/lib/providers/google.js#L12. This is accessible at require('@hapi/bell').providers.google.

For further questions about this the hapi hour slack might be a good bet: https://join.slack.com/t/hapihour/shared_invite/zt-g5ortpsk-ErlnRA2rUcPIWES21oXBOg

All 2 comments

I took a quick look at the documentation for the server-side here: https://developers.google.com/identity/sign-in/android/offline-access. It seems as though the client will obtain an auth token from Google, and if it sends that token to your API then your API will be able to obtain the user's information from Google. I think you will need to create a route to accept this auth code and reach out to Google to turn it into profile information.

I don't believe that bell or any official hapi plugin will do this for you, however bell's google provider configuration should help! You will post to the token endpoint defined here, and you can use the profile mapping logic defined there too: https://github.com/hapijs/bell/blob/master/lib/providers/google.js#L12. This is accessible at require('@hapi/bell').providers.google.

For further questions about this the hapi hour slack might be a good bet: https://join.slack.com/t/hapihour/shared_invite/zt-g5ortpsk-ErlnRA2rUcPIWES21oXBOg

Thank you very much 🙏 for the guidelines.
Take care

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leore picture leore  ·  3Comments

hueniverse picture hueniverse  ·  4Comments

mateeyow picture mateeyow  ·  5Comments

mahnunchik picture mahnunchik  ·  4Comments

AdriVanHoudt picture AdriVanHoudt  ·  5Comments