Authorization from app - java

I write a lite instagram client (Instagram is a part of client).
And I need to the user can authorizate in Instagram without web-form (to I don't need to send the user in his web-browser).
At this moment I use a link https://api.instagram.com/oauth/authorize/?client_id=CLIENT-ID&redirect_uri=REDIRECT-URI&response_type=code.
It sends the user to the web-form where he can input his login and password.
How I can send his login and password programatically without using of the web-brower?

No way to login without the Instagram's web interface. Use a Webview to open the auth URL and redirect back to app.

Related

Java Open a Web Browser to a URI with an HTTP GET Request

I am writing a Java desktop application that uses the last.fm API to download data. I am stuck on the authentication process where the instruction is to:
Open a web browser and send the user to last.fm/api/auth with your API key and auth token as parameters. Use an HTTP GET request.
I do not understand how to open a web browser to a specific URI using an HTTP GET request. Is this possible?
Thanks
Try with Desktop:
Desktop.getDesktop().browse(new URI("http://www.last.fm/api/auth/?api_key=xxxxxxxxxx&token=yyyyyy"));
According to last.fm documentation:
If the user is not logged in to Last.fm, they will be redirected to the login page before being asked to grant your application permission to use their account. On this page they will see the name of your application, along with the application description and logo as supplied in Section 2. Once the user has granted your application permission to use their account, the browser-based process is over and the user is asked to close their browser and return to your application.

OAuth automatic login without user clicking 'LogIn' button

I am trying to login to Facebook using the OAuth log-in mechanism of Scribe which builds a URL https://www.facebook.com/dialog/oauth?client_id=1928545420713067&redirect_uri=http://localhost:23080/integration/auth/facebook/callback&state=a5312c35-ab4f-4690-8086-b6ff6b249f52
It now redirects me to a browser with a login dialog, where I need to enter my username and password and login and then OAuthService triggers the callback.
Is there a way to automate the login mechanism without me typing the 'UserName' and 'Password'values everytime I trigger Oauth authentication but store it somewhere and use it automatically whenever I need to login.
I basically want to get rid off the login dialog and take care of logging-in completely in the back end.
If my understanding is right, You are not using OAuth correctly in first place. To solve the problem you are facing OAuth has given the solution of providing a token instead of password.
On each successful login using OAuth, you will get a token and userid in response. This need to be used next time from program to request user's personal information.
Moreover, you have to atleast allow user to enter username password on authentic facebook screen. In OAuth flow, actual password is never known to requesting site.
See flow here
https://www.digitalocean.com/community/tutorials/an-introduction-to-oauth-2

Android using Google account but without user interaction

I try to develop parental control app and in setup page the parent enters his email to receive location of his kids.
when use JavaMail API using Gmail authentication, need password and email to send email to the parent (and it is not professional way to ask user email and password of his email).
And cannot be used intent because need without user interaction.
So Can anyone Help me or gives me and suggestions
I suggest send emails to user using Google account but without user interaction - If possible-

RESTful webservice with auth for mobile application

I have developed many stateless RESTful webservices for a mobile application in Java and they are working very well.
For example:
http://.../api/coupon
http://.../api/coupon/{id}
...
Now, I have to extend these services because I have to send different data back to the mobile for every user. So I need to know on the server side which user try to get or set information. And I have to prevent the serve of unauthorized users.
There are two different way how user can login into the mobile application:
log in with facebook account
log in with an application account
I need to develop two login and a logout services because the users who use the mobile application have to login into the application.
I read lots of article about auth and RESTful and OAuth.
I think I have to develop two login services with two imput parameters: username and password.
For example:
localLogin(String username, String password) -> token
facebookLogin(String username, String password) -> token
These logon services have to generate a same token and send it back to the mobile application in the http header. And after the login process the mobile client has a token. And the client has to send this token to the server when it makes a RESTful server call.
What do you think? Is my idea good?
If it is, could you help me how can I start to develop this in Java?
If it is not, could you tell me the good way?
You do not need 2 log in procedures. Just use the Facebook SDK!!
i) In your app would be a login with facebook button.
ii) User clicks on it and is then redirected to the facebook login page, where the user enters his credentials and facebook returns a token to you. You do not have to worry about the user's facebook credentials or storing them anywhere! Facebook will handle that for you. Consider the FB login part as black box to your app - you simply make a FB SDK's login call and it will do some processes and give back a access token to your app.
iii) Now, you can exchange the access token for the user's profile information. Enter this profile info to your database - that will ensure authenticated call.
Once you have verified that the user is logged on you can do whatever you want.

automatic login to facebook in java

I have created a java web application using spring. I want the users of my application can be logged automatically into my application when they are logged into facebook. Any help will be highly appreciated.
It depends of your app. BTW, facebook have good documentation about this, you have to use javascript auth (there are many examples), with manually processing result or using facebook-java-api (look at FacebookSignatureUtil for example).
PS you have to register your webapp at facebook before using facebook connect
I don't think it is possible for you to get user to automatically logged into your app. Facebook stores the log in token in a cookie, this cookie will get passed back to same server, not to your server.
The click, will send request to facebook and you will get authentication token from facebook.
In fact, it is possible for facebook login button to log you into site even if user is logged out of facebook. You need to ask for "offline_access" permission.

Categories