• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

oktadev/okta-react-graphql-example: Health Tracking App with React, GraphQL, and ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

oktadev/okta-react-graphql-example

开源软件地址(OpenSource Url):

https://github.com/oktadev/okta-react-graphql-example

开源编程语言(OpenSource Language):

TypeScript 64.5%

开源软件介绍(OpenSource Introduction):

Health Tracking App with React, GraphQL, and TypeORM

This example app shows how to use React, GraphQL, and TypeORM to build a health tracking app and add authentication with Okta.

Please read Build a Health Tracking App with React and GraphQL, and TypeORM to see how this app was created.

Prerequisites: Node.js.

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 https://github.com/oktadeveloper/okta-react-graphql-example.git
cd okta-react-graphql-example

This will get a copy of the project installed locally. To install all of its dependencies and start each app, follow the instructions below.

To run the GraphQL API, cd into the graphql-api folder and install its dependencies:

npm i

This project is configured to use a MySQL database. You can change its settings by modifying graphql-api/ormconfig.json. To create a MySQL database with the default settings, run the following commands:

mysql -u root -p
create database healthpoints;
use healthpoints;
grant all privileges on *.* to 'health'@'localhost' identified by 'points';

After this database exists, start the API with npm start.

To run the client, cd into the react-client folder and run:

npm i
npm start

Setup Okta

Log in to your Okta Developer account (or sign up if you don’t have an account) and navigate to Applications > Add Application. Click Single-Page App, click Next, and give the app a name you’ll remember. Click Done.

Server Configuration

Open graphql-api/index.ts and replace {yourOktadomain} and {yourClientId} in the following code block.

const oktaJwtVerifier = new OktaJwtVerifier({
  clientId: '{yourClientId}',
  issuer: 'https://{yourOktaDomain}/oauth2/default'
});

NOTE: The value of {yourOktaDomain} should be something like dev-123456.oktapreview. Make sure you don't include -admin or two .com in the value!

Client Configuration

For the client, set the issuer and client_id in react-client/src/App.js.

class App extends Component {
  render() {
    return (
      <Router>
        <Security issuer='https://{yourOktaDomain}.com/oauth2/default'
                  client_id='{yourClientId}'
                  redirect_uri={window.location.origin + '/implicit/callback'}
                  onAuthRequired={onAuthRequired}>
          <Route path='/' exact={true} component={Home}/>
          <SecureRoute path='/points' component={Points}/>
          <Route path='/login' render={() => <Login baseUrl='https://dev-669532.oktapreview.com'/>}/>
          <Route path='/implicit/callback' component={ImplicitCallback}/>
        </Security>
      </Router>
    );
  }
}

Links

This example uses the following libraries provided by Okta:

Help

Please post any questions as comments on the blog post, or visit our Okta Developer Forums. You can also email [email protected] if you would like to create a support ticket.

License

Apache 2.0, see LICENSE.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap