How to use Slack's OAuth2 with a Java desktop application - java

Is there a way to authenticate a java desktop application with Slack using OAuth2? I am trying to follow Slack's guide.
I am getting stuck because it says you get the access token inside of the redirect uri of your application. But since the app I am making does not exist inside of the web browser, is there anyway I can do this?
Can my java application launch a localhost site that it can communicate with to use as the redirect uri? If so, how?

Desktop app as internal integration
Before we get into more details please note that there is an easy solution if you plan to use your desktop app for your own Slack workspace ONLY. In that case your app does not need to support the full Oauth work flow and you have two options:
Install your app as internal integration via the management page
of your Slack app and then copy & paste the token to your desktop app
Create a legacy token for your Slack workspace and then copy & paste to your desk (not recommended)
I also like to clarify upfront that your app only needs to run the Oauth process ONCE for installing it into a new Slack workspace. The resulting token has no expiration date and has not to be refrehed.
Desktop app for multiple Slack workspaces
If you plan to distribute your desktop app to multiple Slack workspaces you will need to support the full Oauth installation process.
Slack is using Oauth 2.0, so in principle all the standard answers from this older Oauth wiki article should work for Slack too.
However, since you can not assume that the local machines of your users are reachable from the Internet (e.g. redirecting back to a local web server will not work, since Slack will most likely not be able to reach it), you will need a web helper app that runs on a web server and is reachable from the Internet.
This web helper app is basically a small web site, which performs the complete Oauth dance for the installation process into a new Slack workspace. You app can open a browser window and redirect to the web helper app to start the login process. You then have two basic approaches how to handle the connect back to your desktop app:
Show the resulting token to the user and ask him to copy & paste it
to your desktop app (simple approach)
Store the resulting token in your web helper app and provide an API to your desktop app to fetch it automatically. (user-friendly approach)
If you are looking for a starting point for such a web helper app, take a look at this example PHP script for installing Slack apps.

Related

This app isn't verified This app hasn't been verified by Google yet. Only proceed if you know and trust the developer

Hi I have developed an web application using google app engine, for google shared domain contact, Its working fine when I am running it in the localhost but when I deploy that application into google app engine it showing warning screen before user conforming for consent(as shown in the image).
I am using 2 scope http://www.google.com/m8/feeds/contacts/ and https://www.googleapis.com/auth/userinfo.email. when I try to add a user information in the google shared contact I am getting a exception message as www.google.com. How can I resolve the problem? am i need to verify my application in the oauth_app_verification. Can any one solve this?
Thank you.,
You need to go through the verification process before you launch your app. This new process came recently to protect user's data. You can start the verification by submitting this form but before it is recommended to follow steps here

Using Steam Web API from an Android app

I am trying to add some information from Steam into my Android app.
I see that Steam has Steamworks, but that is only built for Windows, OSX and Linux.
Furthermore, I saw that they also have a Web API that could also be accessed from a mobile application. But all the methods in the API require a 64 bit SteamID, which they say can be retrieved using OpenID. I downloaded the Google Oauth Client Library for JAVA but I reading through the documentation, I don't understand how I can get a SteamID for a user using this library.
Has anyone used this lib or another open source lib to get a SteamID?
UPDATE
To get direct SteamID64.
Login to Steam using a web broswer.
Once logged click on your profile and add ?xml=1 to browser url address
http://steamcommunity.com/id/yourusername/?xml=1 or
http://steamcommunity.com/profiles/yourprofilenumber/?xml=1 (if you have not set a public username yet)
I think this is number in profile link or steamID64 example: http://steamcommunity.com/profiles/76561198113616635
Steamid will be: 76561198113616635
To check it online you can go to https://steamid.io/lookup
In Android app, I think after authorize, steam will give you that number and key.

Integrate a finished web service in a Android application

I don't know if the correct term is "integrate" or "connect" a finished web service in a android application. I mean,
Is there any possibility to "integrate" a finished RESTful Web Service in a Android application, which I have not developed, yet.?
Otherwise,
Are there some steps to develop a RESTful web service which I need to use from a Android application?
The last question is asked because I don't know if the first step is to finish my RESTful Web Service and then integrate it in my android application or or developing the RESTful web service and the android application at the same time.
In any case, how I can do it well? I need help to organise my mind
You will need three things:
Client(your app)
Server
Database
Lets say you have to create a login service for your app. Then your steps should be like given below:
Create a login form with android UI.
Get username and password from Edit Texts in strings.
Send these credentials to server(via http reqest).
At client side read response from url via input stream.
At the server side, use a server side technology in which you are familiar with.(If you are not familiar with any server side tech. I strongly recommend you php.)
Select/update/compare (Whatever you want) in data base and return response as a json string.
You can use server on your system. I suggest to use XAMPP(cross platform apache mysql php perl). As its name says, it includes server+database+php (its local). It will create a local apache server on your machine.
Follow this : XAMPP Tutorial , Working with XAMPP
Here are some nice tutorials of web services with android:
How to connect Android with PHP, MySQL
Using Database from an Android Application

Java Applet and Storage Access

We're developing an app that will be running embedded within a browser using secure sockets to communicate with a server. I want to add the ability for the applet to save its state (locally) so when they next open the page, the app can recall where the user was.
I've been looking into CookieManagers and Java Web Start with JNLP, but I'm unsure where to begin and what would be the best solution.
Any reccomendations? :)
Accomplished using self certification now. The user grants the application permission and then the application can read and write from the file system.
I used this article for signing the app: http://www.jade-cheng.com/uh/ta/signed-applet-tutorial/

Remember the last oAuth2 session for Google Drive API in Desktop application

Previously, in order to use Google Drive service, we are using the following simple username and password login in Desktop application with Google Documents List API
DocsService client = new DocsService(getCloudApplicationName());
client.setUserCredentials(username, password);
As in Google announcement, https://developers.google.com/google-apps/documents-list/, Version 3 of the Google Documents List API has been officially deprecated as of September 14, 2012. It will continue to work as per our deprecation policy, but we encourage you to move to the Google Drive API.
So, in our desktop Swing application, we need to rewrite the code to gain authentication to Google Drive service.
By referring to code example run at console https://developers.google.com/drive/quickstart-java#step_3_set_up_the_sample
Please open the following URL in your browser then type the authorization code:
https://accounts.google.com/o/oauth2/auth?access_type=online&client_id=888888888888.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&response_type=code&scope=https://www.googleapis.com/auth/drive
User need to open up the browser manually.
Key in his username and password.
He will then obtain a special string from browser, where he needs to copy and paste to the console.
I think I can pretty much simply the process, by using a web view component Integrating JavaFX 2.0 WebView into a Swing Java SE 6 Application, so that the above task will be automated.
However, the webview's component previous history session will be destroyed as I close my desktop Swing application. User need to key in his password and username every-time he launch the desktop app.
From official Google Drive app for Windows, I realize it does have the capability to remember the last authentication of the user. User just need to key in his username and password once. He can then use the Google Drive service again and again, even after restarting the computer.
May I know how I can achieve the similar behavior?
You need to permanently store web view's cookies and set them again once you launch the web view again.

Categories