# auth-oauth-device.js > GitHub OAuth Device authentication strategy for JavaScript [](https://www.npmjs.com/package/@octokit/auth-oauth-device) [](https://github.com/octokit/auth-oauth-device.js/actions?query=workflow%3ATest+branch%3Amain) `@octokit/auth-oauth-device` is implementing one of [GitHub’s OAuth Device Flow](https://docs.github.com/en/developers/apps/authorizing-oauth-apps#device-flow). - [Usage](#usage) - [For OAuth Apps](#for-oauth-apps) - [For GitHub Apps](#for-github-apps) - [`createOAuthDeviceAuth(options)`](#createoauthdeviceauthoptions) - [`auth(options)`](#authoptions) - [Authentication object](#authentication-object) - [OAuth APP user authentication](#oauth-app-user-authentication) - [GitHub APP user authentication with expiring tokens disabled](#github-app-user-authentication-with-expiring-tokens-disabled) - [GitHub APP user authentication with expiring tokens enabled](#github-app-user-authentication-with-expiring-tokens-enabled) - [`auth.hook(request, route, parameters)` or `auth.hook(request, options)`](#authhookrequest-route-parameters-or-authhookrequest-options) - [Types](#types) - [How it works](#how-it-works) - [Contributing](#contributing) - [License](#license) ## Usage
| Browsers | Load `@octokit/auth-oauth-device` directly from [cdn.pika.dev](https://cdn.pika.dev) ```html ``` |
|---|---|
| Node | Install with `npm install @octokit/core @octokit/auth-oauth-device` ```js const { createOAuthDeviceAuth } = require("@octokit/auth-oauth-device"); ``` |
| name | type | description |
|---|---|---|
clientId
|
string
|
Required. Find your OAuth app’s Client ID in your account’s developer settings.
|
onVerification
|
function
|
Required. A function that is called once the device and user codes were retrieved The `onVerification()` callback can be used to pause until the user completes step 2, which might result in a better user experience. ```js const auth = createOAuthDeviceAuth({ clientId: "1234567890abcdef1234", onVerification(verification) { console.log("Open %s", verification.verification_uri); console.log("Enter code: %s", verification.user_code); await prompt("press enter when you are ready to continue"); }, }); ``` |
clientType
|
string
|
Must be either `oauth-app` or `github-app`. Defaults to `oauth-app`. |
request
|
function
|
You can pass in your own @octokit/request instance. For usage with enterprise, set baseUrl to the API root endpoint. Example:
```js
const { request } = require("@octokit/request");
createOAuthDeviceAuth({
clientId: "1234567890abcdef1234",
clientSecret: "secret",
request: request.defaults({
baseUrl: "https://ghe.my-company.com/api/v3",
}),
});
```
|
scopes
|
array of strings
|
Only relavant if `clientType` is set to `"oauth-app"`. Array of scope names enabled for the token. Defaults to `[]`. See [available scopes](https://docs.github.com/en/developers/apps/scopes-for-oauth-apps#available-scopes). |
| name | type | description |
|---|---|---|
type
|
string
|
Required. Must be set to "oauth"
|
scopes
|
array of strings
|
Only relevant if the `clientType` strategy options was set to `"oauth-app"` Array of scope names enabled for the token. Defaults to what was set in the [strategy options](#createoauthdeviceauthoptions). See available scopes |
refresh
|
boolean
|
Defaults to `false`. When set to `false`, calling `auth(options)` will resolve with a token that was previously created for the same scopes if it exists. If set to `true` a new token will always be created. |
| name | type | description |
|---|---|---|
type
|
string
|
"token"
|
tokenType
|
string
|
"oauth"
|
clientType
|
string
|
"github-app"
|
clientId
|
string
|
The app's Client ID
|
token
|
string
|
The personal access token |
scopes
|
array of strings
|
array of scope names enabled for the token |
| name | type | description |
|---|---|---|
type
|
string
|
"token"
|
tokenType
|
string
|
"oauth"
|
clientType
|
string
|
"github-app"
|
clientId
|
string
|
The app's Client ID
|
token
|
string
|
The personal access token |
| name | type | description |
|---|---|---|
type
|
string
|
"token"
|
tokenType
|
string
|
"oauth"
|
clientType
|
string
|
"github-app"
|
clientId
|
string
|
The app's Client ID
|
token
|
string
|
The user access token |
refreshToken
|
string
|
The refresh token |
expiresAt
|
string
|
Date timestamp in ISO 8601 standard. Example: 2022-01-01T08:00:0.000Z
|
refreshTokenExpiresAt
|
string
|
Date timestamp in ISO 8601 standard. Example: 2021-07-01T00:00:0.000Z
|