---
# System prepended metadata

title: OKTA 懶人包

---

### Step 1
- 請後端將自己的 email 加入到組織
- 去該 email 收信起用
![](https://hackmd.io/_uploads/H1yrleqjh.png)

### Step 2
- call 下面 API
- redirectUrl 要換成後端的首頁網址
```graphql
mutation CreateOktaOidcFlow {
  createOktaOidcFlow(input: {
    redirectUri: "http://dev.4idps.com.tw:4301/"
  }) {
    id
    redirectToOktaUri
  }
}
```

### step3
- 複製網址 step= 後面的字串，貼到 id
- 複製網址 code= 後面的字串，貼到 oktaAuthCode

```graphql
mutation CreatePianoTokenFromOktaOidcFlow {
  createPianoTokenFromOktaOidcFlow(input: {
    id: "cUwL2t340WraUGwtCO_q5"
    oktaAuthCode: "siAj-nPbeefNcAU93nZJE4mREp2od7qxNAVIaKbjDAU"
  }) {
    oktaTokenResponseStatus
    oktaTokenResponse {
      pianoToken {
        accessToken
      }
    }
  }
}
```

### step4
- set shared headers
- 第一格填: Authorization 
- 第二格填: Bearer ${accessToken}
    - accessToken 是上面 API 回傳

### step5 (optional)
確認 user table 有資料

```graphql
query Me {
  me {
    id
    email
    name
    isActive
  }
}
```




