I've written an android app to get my account usage such as Voice data usage, SMS data usage from Ringplus site (ringplus.net).
Ringplus API (https://docs.ringplus.net/) uses Oauth2. And the app that I wrote has hard coded client id & secret for my account.
Now, everything works fine for my account. But I want to give this app to my friend so that he can also use it to view his account usage.
With client id & secret hardcoded, how would that work for my friend?
Also, when I created app in Ringplus website, I just added redirect_uri as something which does not exist like http://localhost since I don't have anything hosted.
So, my question is how do I distribute my app with client id & secret hard coded?
Thanks
If I am not wrong the client ID and secret are for the API access. That one cannot be replaced and needs to be present for the application to successfully authentication / authorize with the API.
If you are not keen on sharing you client id and secret than you can provide a preferences screen in the android app, for the user to enter that information. But the user would need to sign up for the API (as you did). Use the information entered in the SharedPreferences can be use to connect to the API.
You should store client secret in a server. Upon receiving the code by sending clientid to ringplus you will get code to your server redirect uri. From here you can send the client secret to ringplus and send authentication token to the user
Related
I have discovered that basic authentication to email account no longer works, when using java.mail library. It seems that an OAuth2 based authentication is needed. I need help in defining the actual steps. I have created a sample app in Azure and granted the IMAP, POP and SMTP permissions to it, but I don't know what are the next steps, how to actually tell my email reader (in Java code) that it should use this app and actually connect to the email inbox. The email server is a Microsoft Exchange server.
So i came across this Less secure apps & your Google Account link, And it states that after the 30th of may this year, Enabling 'less secure apps' option will no longer be available.
I was wondering if there will be any alternative? I need to be able to read emails and download attachments through my application without the user having to do so himself, So the Gmail API is no good as far as i could see.
I also couldn't find any other option to access a gmail inbox without enabling this option... Ty for your time.
The whole point of this is that you should not be using someone's login and password to access gmail. You could try using an apps password but it is unlcear if this will work or not in the long run. Google has been very vague about that.
You should be authorizing the user either using Xoauth2 for the smtp server or by using the Gmail api and authorizing the user.
With oauth you can request a refresh token and then you will only need to request the users permission once after that you can use your refresh token to request a new access token.
The java mailer API works on password authentication(username and password). And if you want to use it with Gmail SMTP Server Address as the host you need to allow access less secure apps in your email account but this option is not available since may 30, this password authentication method will not work using gmail.
The option you can have is to use the gmail API to read/write to your gmail account another option is to use oauth2 to authenticate the account and save the tokens to the file so that you can use it to authenticate every time you call the api. For more on authorizing your app with google click here
So I'm all very new to Java and developing for Android, but I somehow managed to get a successful idToken when logging into my app via Google.
I read on the Android dev site that just ID's are not safe as a modified client could send a fake one and result in impersonation of another user, so I followed their steps to get the user's idToken.
Anyway, is this safe to send over a URL to my server at home? For example, like so (pretend the long string of random text is the idToken of the user):
http://130.155.122.8/api_test/h78e568e7g6589gjkdfhjghdjfkghjkdfhgjkdfhk7hg9867458g74598hg6745896gh49/command
Also, is the idToken even required? Could I just as easily use the user's email address to identify the user (again, it would be sent over an insecure URL, no HTTPS)?
Thanks!
You should use encryption, if someone gets the token from a user they can impersonate that user, in my case, since i can't aford ssl (for now) i encrypt the token using asymetric encryption, and i send it to the server, but ssl is the best way
Generally speaking - No.
A token that identifies you should never be transmitted over an insecure connection (e.g. http). Since on such connections no encryption is used, a third party can very easily monitor the connection and get your token (leading to the impersonation issue).
IANAE, but any security-relevant data (e.g. idToken or password) should only ever be transmitted over a secure (encrypted) connection (e.g. https).
And using the e-mail address does not solve the issue. You simply replaced one identifier for another one. And if anyone ever were to know a user's e-mail address, he could impersonate said user. Stick to the "documented" authentication techniques. If done right they should be safe.
I came across this online document, and from there there is slide about GWT Offline authentication:
When online, authentication is done by the server.
We should then be able to re-authenticate him/her without the server.
Be careful ! Local storage completely unsecure !
We thus store the user’s password in the browser, salted and
crypted with SHA-3.
Find a Java SHA-3 implementation, copy-paste in the project :
String shaEncoded = SHA3.digest( String clearString );
Offline HTML5 apps with GWT 18
The questions are:
Is it really possible to securely authenticate a GWT application with this approach? If it's SHA-3 encoded would it really make it secure?
When user gets authentiated in the browser, then user uses the offline app, say save stuff, then surely it is just stored in the HTML5 Storage, however with the User info embedded perhaps in anything saved. Thus, when app gets back online, it will sync to the server. How is this secure? Would the server just accept that the thing it is syncing really is from the right user?
There is no special case for offline regarding authentication. It works the same as with online.
You will usually have a Cookie with session information stored in your Client's browser which is used to authenticate the client with the server (when you are making a request).
As long as the session information is persistent on the backend, you can re-authenticate the user.
You must not store the password on the client side. Its is enough to store some session information on the client (either in a Cookie or LocalStorage) and use that to authenticate the user.
Actually you are not storing the password itself in the browser, but its SHA-3 hash.
From a cryptography perspective this approach is very secure as it is not easily possible to retrieve the original password.
Just note:
Your code will be stored on the client side and every source code on the client can be tampered with. So also a malicious user might be able to read and exploit it.
But don't worry, for the ordinary use case of an offline usable application, this is secure enough.
What I would do for long running server sessions:
Generate a random ID on the server side, associate it with the user and store it i.e. in a database.
Set the ID as a cookie on the client and re-authenticate the user whenever he is not logged in and still has this ID in a cookie.
To limit the amount of time you can add a timeout value on the server side after which the ID is discarded.
I'm currently developing an android app where the user has to fill out and successfully send the data of a few text fields to a recipient/server, to enable a feature.
The big issue is how to do that in a secure way to be protected against e.g. decompiling. My concern is not the security during the transport but rather the security of the transport medium.
What I've thought/read so far:
I could send the data via mail with the Java Mail API.
First of all, I don't want require that the user has to enter his mail credentials and SMTP server.
That would mean that I have to include the credentials to a mail account in the app, though.
To avoid the situation that somebody decompiles the app and takes over my mail account, I thought of encrypting methods, but even if I would save the aes encrypted version of the password, the attacker could decompile the app and could add a syso to output the decrypted password.
The same applies to OAuth authentication because I have to store an authentication token.
In addition to the mail version, I read something about getting the password with a POST request from a web service, which doesn't seem safer at all.
I could search for free smtp server without the need of credentials, but I want something I can rely on instead of waking up each day and looking if the service still works.
Send the data to a web service.
Okay that would require more work for me, but I would accept that, if there would be a solution without saving the credentials in the app or having a web service which accepts data from everybody.
Have I overlooked something? Or is there no safe method without asking the user for his mail credentials or google account etc. ?
OAuth would probably work. The nice thing about OAuth is that if a token is compromised it can be revoked on the server side.
You could create a web service that accepts TCP connections on some port. You could have some authentication mechanism for example Digest authentication that would be carried out before accepting data.
Another option would be to use an API such as Golgi. Golgi requires a developer key, app key and app instance id to connect to the servers and send data. In the event these credentials somehow get compromised you can simply change the app key and push a new version of the app through the Play Store.