Share data between two android applications


#1

Hi, i am working on two different projects. I want to login from one app and save the login token. When user want to use second app, then instead of login again by providing email and password from second app. He should login by using the token generated by first app. Is there some available for this scenario.


#2

You need to declare the same android:sharedUserId in both applications and sign them with the same key, at which point they should be able to read one another’s data.


#5

in general you should not do it…
never ever share auth token or sessions.

Maybe you should not provide two apps and merge both functionalities in one.


#6

@bengtler, it is a client requirement. User have to login from one application and use that login token on other app to use the app.


#7

yeah but then you need to store the token somewhere persistent, which is a high security issue.
I would build something like deeplinking. After login in the first app --> provide a link to open the second app and there you pass the token, which is used in the second app


#8

@bengtler Actually, the ioS has a mechanism of storing data in keychain, I am looking similar thing. And i cannot give the link to the second app in first. because it is up to the user if he want to use the second app or not.


#9

then use https://ionicframework.com/docs/native/app-availability/

to check if the app is installed, and then show a button “SSO for app XXX”.

Then you have a clear workflow und a single mechanism to share the token


#10

@bengtler I can not do this, because client does not want this. I have to share token, when the user login from first app and when user use the second app, he will access the token there. for this scenario is there anything available?


#11

write the token in a file and access the file. you should be able because they share the userId (like @rapropos) guided you