Giter VIP home page Giter VIP logo

fusionauth-java-client's Introduction

FusionAuth Java Client semver 2.0.0 compliant

If you're integrating FusionAuth with a Java application, this library will speed up your development time.

For additional information and documentation on FusionAuth refer to https://fusionauth.io.

Example Usage

Build the Client

String apiKey = "5a826da2-1e3a-49df-85ba-cd88575e4e9d";
FusionAuthClient client = new FusionAuthClient(apiKey, "http://localhost:9011");

Login a user

UUID applicationId = UUID.fromString("68364852-7a38-4e15-8c48-394eceafa601");

LoginRequest request = new LoginRequest(applicationId, "[email protected]", null, "abc123");
ClientResponse<LoginResponse, Errors> result = client.login(request);
if (!result.wasSuccessful()) {
 // Error
}

// Hooray! Success

Installation

Add the dependency via Maven:

<dependency>
  <groupId>io.fusionauth</groupId>
  <artifactId>fusionauth-java-client</artifactId>
  <version>1.46.0</version>
</dependency>

Building

Building with Maven

$ mvn install

Building with Savant

Note: This project uses the Savant build tool. To compile using Savant, follow these instructions:

mkdir ~/savant
cd ~/savant
wget http://savant.inversoft.org/org/savantbuild/savant-core/2.0.0-RC.6/savant-2.0.0-RC.6.tar.gz
tar xvfz savant-2.0.0-RC.6.tar.gz
ln -s ./savant-2.0.0-RC.6 current
export PATH=$PATH:~/savant/current/bin/

Then, perform an integration build of the project by running:

$ sb int

For more information, checkout savantbuild.org.

Questions and support

If you have a question or support issue regarding this client library, we'd love to hear from you.

If you have a paid edition with support included, please open a ticket in your account portal. Learn more about paid editions here.

Otherwise, please post your question in the community forum.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/FusionAuth/fusionauth-java-client.

License

This code is available as open source under the terms of the Apache v2.0 License.

fusionauth-java-client's People

Contributors

bhalsey avatar jobannon avatar matthew-altman avatar mooreds avatar robfusion avatar robotdan avatar spwitt avatar trex avatar tyduptyler13 avatar voidmain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fusionauth-java-client's Issues

Ability to create Application level API Key

I had verified on stackoverflow that this feature is not available and was asked to create it as a feature request in github.
Currently there is no support to create an application level API key thru java client. This feature will be very helpful when we are creating tenants/applications thru java client and we have to switch to web interface for creating api key.

Maven central out of sync with releases and dependencies

Hi there!

It seems maven central publications are not in sync with actual releases, but rather lagging behind a couple of versions. Furthermore, the latest java client available (as of writing), 1.17.0, has a dependency to com.inversoft:restify:3.4.1 which is also not published, making this version fail to satisfy it's deps.

Thanks.

Getting socket failed: EACCES (Permission denied)

I have created a test server to check how things are. I have created an Applications, added a user manually, registered application to user, and created a password using the link given in email.

        String apiKey = "xxx";
        FusionAuthClient client = new FusionAuthClient(apiKey, "http://142.93.213.217:9011");
        final UUID applicationId = UUID.fromString("yyyy");

        LoginRequest request = new LoginRequest(applicationId, "[email protected]", "zzzzxxxxss");
        ClientResponse<LoginResponse, Errors> result = client.login(request);
        if (!result.wasSuccessful()) {
            Log.e(TAG, "Could not Authenticate");
        }else{
            Log.d(TAG, "Logged in Successfully");
        }

But I am still not able to login the user. Am I missing anything? It seems like the apiKey is wrong and hence I am unable to connect to the server. I am able to get the user using Node client API on the server side so I guess the setup of FusionAuth is correct. The error does not elaborate where I am wrong in the above steps and hence I am unable to debug.

I am able to use the login API in Postman.

Create user does not set roles

In my project I have built the following request object using Kotlin. The Java Client version I was using is 1.34.1

// data is a pojo from a method of my service.
        val request = UserRequest(
            User().apply {
                email = data.email
                mobilePhone = data.phoneNumber
                firstName = data.firstName
                lastName = data.lastName
                password = randomAlphanumericString(8)
                username = data.firstName.lowercase() + "_" + randomAlphanumericString(6)
                registrations.add(
                    UserRegistration().apply {
                        roles =sortedSetOf("ROLE_USER")
                        applicationId = myapplicationId 
                    }
                )
            }
        ).apply { applicationId = myapplicationId }
        log.debug("create user request: $request")
        client.createUser(UUID.randomUUID(), request)  

When it is executed, I found I can not get roles from the response.user.getRolesOfApplicaiton(). It seems the uesr registration data in the user request is no use at all.

username in user registration is no use when registering a user

I was trying to use register to add a new user.

        val request = RegistrationRequest(
            User().apply {
                firstName = data.firstName
                lastName = data.lastName
                email = data.email
                mobilePhone = data.phoneNumber
                password = randomAlphanumericString(8)
                username = data.firstName.lowercase() + "_" + randomAlphanumericString(6)
            },
            UserRegistration().apply {
                roles =sortedSetOf<String>("ADMIN")
                applicationId = mapplicationId
                // if set here, username is not stored.
                // username = data.firstName.lowercase() + "_" + randomAlphanumericString(6)
            }
        )
            client.register(UUID.randomUUID(), request)

If I put the username in the UserRegistration, the result will not contain the username. I have to put it into the User object.

Here register will affect the getRolesOfApplication.

I really do not understand the APIs provided in the Java Client. I can not imagine a request object contains so many fields, but most of them are no use.

Search users using database search engine ?

Hello, with the Java client we are searching Users in FusionAuth that are in a specific Group, using the method client.searchUsersByQuery(). We currently use Elasticsearch as search engine, but it seems to be slow even with the local install (270 Groups, 500 Users in total). So we would like to compare performance to using the database search engine (PosgreSQL).

Although this search request (Users in a Group) does not require a JSON request body but can be handled via URL parameters (queryString), the Java client still calls the user search API with a JSON request body. The docs state that advanced queries via a JSON request body are not possible with the database search engine. My question is if it is possible to use the Java client for user search without JSON request body, but only queryString as URL parameter? Since I could not find this in the docs or Java code, I am asking here.

Create User -> Update User -> Not Found in Elasticsearch query

Hello, we are using FusionAuth 1.22.0 with Search: Elasticsearch and Database: PostgreSQL. We use the FusionAuth Java client (1.18.0) to communicate with the FusionAuth API.

What goes wrong is this:

  • we create a new User via FusionAuthClient.createUser(UUID userId, UserRequest request)
  • we add a Group membership for an existing Group for this User via FusionAuthClient.createGroupMembers(MemberRequest request)
  • we refresh the index via FusionAuthClient..refreshUserSearchIndex()
  • we retrieve the new User via FusionAuthClient.retrieveUser(UUID userId)
  • we retrieve all Users in the Group we added the new User to via FusionAuthClient.retrieveGroup(UUID groupId) and the new User is included
  • next, we update the new User (change name) via FusionAuthClient.updateUser(UUID userId, UserRequest request)
  • we refresh the index via FusionAuthClient..refreshUserSearchIndex()
  • then, we again retrieve all Users in the Group (as above) but now the new and updated User is NOT included !
  • a GET query on the Elasticsearch index fusionauth_users to retrieve all Users in the Group yields the same result: the new and updated User is NOT included
  • in the FusionAuth UI, the User is present with the new name and correct Group membership
  • after doing a reindex in the FusionAuth UI via System > Reindex and again running the query (via Java client or directly on Elasticsearch index) yields the correct result
  • however, repeating the above (adding and updating a User) yields the same results

So the question is whether this is a bug or whether we are doing something wrong?

Java 7 / Android client support

I am facing the following error
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Ljava/time/ZonedDateTime;

The environment is android and it would be really helpful if you could guide me the path of least changes to fix this for Java 7. I would want to uses the Models classes in Java Client and even the serialisers and deserialisers but currently they are dependent on JacksonModule.

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.