Code Monkey home page Code Monkey logo

okta-graphql-java-example's Introduction

Java + GraphQL Example

This example app shows how to create a GraphQL API with Java and secure it with Okta.

Please read How to GraphQL in Java to see how this app was created.

Prerequisites: Java 8 and an Okta Developer Account

Okta has Authentication and User Management APIs that reduce development time with instant-on, scalable user infrastructure. Okta's intuitive API and expert support make it easy for developers to authenticate, manage, and secure users and roles in any application.

Getting Started

To install this example application, run the following commands:

git clone [email protected]:oktadeveloper/okta-graphql-java-example.git
cd okta-graphql-java-example

Create an Application in Okta

Run the Okta Maven Plugin to create an account, register an OIDC app, and configure this app to use it.

./mvnw com.okta:okta-maven-plugin:setup

If you already have an account, you can do it manually.

  1. Log in to your developer account on developer.okta.com.
  2. Navigate to Applications and click on Add Application.
  3. Select Web and click Next.
  4. Give the application a name, add http://localhost:8080/login/oauth2/code/okta as a Login redirect URI, and click Done.

In the src/main/resources/application.properties file, add the settings from your new OIDC app. You won't need to do this step if you used the Okta Maven Plugin.

okta.oauth2.issuer=https://{yourOktaDomain}/oauth2/default
okta.oauth2.client-secret={yourClientSecret}
okta.oauth2.client-id={yourClientId}

Start the app using ./mvnw spring-boot:run, navigate to http://localhost:8080/my-access-token, grab the token, and use it with HTTPie as follows:

http POST http://localhost:8080/graphql query='{foods{id,name}}' 'Authorization: <your_access_token>'

For more information, please read this repo's associated blog post.

Links

This example uses the following open source libraries:

Help

Please post any questions as comments on the blog post, or visit our Okta Developer Forums.

License

Apache 2.0, see LICENSE.

okta-graphql-java-example's People

Contributors

thiago-negri avatar

Watchers

 avatar

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.