Giter Site home page Giter Site logo

singpass / android-singpass-in-app-browser-login-demo Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 2.0 48.76 MB

This repository demonstrates and details the implementation using Chrome Custom Tabs or external web browsers to initiate a Singpass login using Oauth PKCE flow

Kotlin 100.00%

android-singpass-in-app-browser-login-demo's People

Contributors

kenneth-leong-gt avatar

Stargazers

 avatar  avatar

Watchers

 avatar

android-singpass-in-app-browser-login-demo's Issues

[QUESTION] : is there a way to make this work in Flutter app ?

Hi, i need to ask this question

Is there a way to make this work on Flutter app ?
I have made some kind of workaround by opening the intent://link.... url on the external web browser (so it can open the SingPass app), but after user approve the login, it's not triggering the app link url provided in the redirect_uri.

Since AppAuth library for flutter cannot set the state to null, i can't implement this in Flutter using that library.

Chrome keeps prompting to open app

Hi Kenneth, moving to the external browser approach appears to cause Chrome to keep prompting users whether they want to open the RP app after they are redirected back to the browser from the SP app after authenticating. Do you have any advice on how to work around this issue as it is causing security concerns among users that there are so many redirects and different apps opening in just a single login attempt? We noticed the same prompt in your animated gif of your SingPass Demo (Chrome Custom Tab) implementation.

Also, can i clarify on your use of the term "in-app browser"? Because for most people and on most websites written about this topic, "in-app browser" is synonymous with WebView, but i think you meant to say standalone browser or external browser instead, thanks!
Screenshot_2023-06-27-11-51-58-204_com android chrome~2

Rgds,
Andrew

Error: Failed to authorize: [error: null, description: Response state param did not match request state]

In my flutter mobile app, I've been using the flutter_appauth package for SingPass SSO integration and I'm facing an issue during the authorization phase. Specifically, the following error is returned when the application is redirected back from the browser after the user has authenticated:

PlatformException(authorize_and_exchange_code_failed, Failed to authorize: [error: null, description: Response state param did not match request state], null, null)

Here is the code I'm using for the authorizeAndExchangeCode method:

import 'package:flutter_appauth/flutter_appauth.dart';

class SingPassLogin {
  final FlutterAppAuth appAuth = FlutterAppAuth();

  Future login() async {
    // configuration of the SingPass authentication
    final AuthorizationServiceConfiguration _serviceConfiguration =
    AuthorizationServiceConfiguration(
        authorizationEndpoint: 'https://test.api.myinfo.gov.sg/com/v4/authorize',
        tokenEndpoint: 'https://test.api.myinfo.gov.sg/com/v4/token'
    );

    try {
      final AuthorizationTokenResponse? result = await appAuth.authorizeAndExchangeCode(
        AuthorizationTokenRequest(
          'STG2-MYINFO-SELF-TEST',
          'sg.gov.singpass.app://ndisample.gov.sg/rp/sample',
          issuer: 'https://test.api.myinfo.gov.sg',
          scopes: ['name',],
          additionalParameters: <String, String>{
            'purpose_id': 'demonstration'
          },
          serviceConfiguration: _serviceConfiguration,
          responseMode: 'code',
        ),
      );

      print('Access token: $result');
    } catch (e) {
      print('Error occurred during login: $e');
    }
  }
}

My understanding is that flutter_appauth should be handling the state parameter automatically. I do not manually set the state parameter anywhere.

Any help or guidance on this issue would be greatly appreciated.

Not able to login

I downloaded the source and run the app. Now I am getting "Expected URL scheme 'http' or 'https' but no colon was found" error when I click the login with singpass. Please help me on this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.