Git Product home page Git Product logo

Comments (15)

cdawei avatar cdawei commented on July 23, 2024 1

This page might be useful for converting the authData between a String and a Map https://docs.flutter.dev/data-and-backend/serialization/json

from solidpod.

cdawei avatar cdawei commented on July 23, 2024 1

So Anushka mentioned that re-creating the client instance can be done through:

var client = Client(issuer, _clientId, clientSecret: _clientSecret);

where both the _clientId and _clientSecret are strings (so can be serialised).
The issuer variable can be recreated through:

Issuer issuer = await Issuer.discover(issuerUri);

where issuerUri is the same as the one when calling the authenticate function.

Therefore, it seems that we should be able to recreate the client instance by saving the _clientId, _clientSecret and issuerUri.

from solidpod.

junhaow1 avatar junhaow1 commented on July 23, 2024 1

So Anushka mentioned that re-creating the client instance can be done through:

var client = Client(issuer, _clientId, clientSecret: _clientSecret);

where both the _clientId and _clientSecret are strings (so can be serialised). The issuer variable can be recreated through:

Issuer issuer = await Issuer.discover(issuerUri);

where issuerUri is the same as the one when calling the authenticate function.

Therefore, it seems that we should be able to recreate the client instance by saving the _clientId, _clientSecret and issuerUri.

Thanks @cdawei on it

from solidpod.

gjwgit avatar gjwgit commented on July 23, 2024

Could this be assigned to Kevin? Start to have a look at how this will work. Thanks.

from solidpod.

junhaow1 avatar junhaow1 commented on July 23, 2024

Assign myself to this ticket

from solidpod.

junhaow1 avatar junhaow1 commented on July 23, 2024

https://github.com/anusii/solidpod/tree/kev/3_popup
working branch

from solidpod.

junhaow1 avatar junhaow1 commented on July 23, 2024
image image image

from solidpod.

junhaow1 avatar junhaow1 commented on July 23, 2024

solidpod repo:
#57

keypod repo:
anusii/keypod#51

PR created

from solidpod.

junhaow1 avatar junhaow1 commented on July 23, 2024

in progress, working on saving auth data/token for use on other pages as in SolidLogin()

from solidpod.

junhaow1 avatar junhaow1 commented on July 23, 2024

I converted authdata (Map format) into String using serializeMap so that we can save them in secureStorage. But I found difficulty converting the string back to the correct map format. Dawei suggested I can convert the map into Json format first, then save as a string using secureStorage.

from solidpod.

junhaow1 avatar junhaow1 commented on July 23, 2024

/// Store authentication data
authData = {
'client': client,
'rsaInfo': rsaResults,
'authResponse': authResponse,
'tokenResponse': tokenResponse,
'accessToken': accessToken,
'idToken': tokenResponse.idToken,
'refreshToken': tokenResponse.refreshToken,
'expiresIn': tokenResponse.expiresIn,
'logoutUrl': _logoutUrl
};

how to Serialize JSON for each map value .

error I got: Converting object to an encodable object failed: Instance of 'Clientโ€™

from solidpod.

junhaow1 avatar junhaow1 commented on July 23, 2024

demo video:

image
video1107929422.mp4

from solidpod.

junhaow1 avatar junhaow1 commented on July 23, 2024
       // Get the authentication data from the secure storage.

                                      const storage =
                                          FlutterSecureStorage();
                                      String? jsonAuthData = await storage
                                          .read(key: 'authData');
                                      Map<String, dynamic> deserializedMap =
                                          json.decode(jsonAuthData!);
                                      var rsaInfo =
                                          deserializedMap['rsaInfo'];
                                      KeyPair deserializedKeyPair = KeyPair(
                                        rsaInfo['rsa']['publicKey'],
                                        rsaInfo['rsa']['privateKey'],
                                      );
                                      var pubKeyJwk = rsaInfo['pubKeyJwk'];
                                      Map<String, dynamic> authData = {
                                        'accessToken':
                                            deserializedMap['accessToken'],
                                        'rsaInfo': {
                                          'rsa': deserializedKeyPair,
                                          'pubKeyJwk': pubKeyJwk,
                                        },
                                      };
image

from solidpod.

junhaow1 avatar junhaow1 commented on July 23, 2024

https://github.com/anusii/bstim/pull/364

#57

PR created

from solidpod.

gjwgit avatar gjwgit commented on July 23, 2024

Let's review this today - that it is fully functional.

from solidpod.

Related Issues (20)

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.