2.1.2 • Published 5 years ago

@octokit/oauth-login-url v2.1.2

Weekly downloads
43
License
MIT
Repository
github
Last release
5 years ago

oauth-login-url.js

Universal library to retrieve GitHub’s identity URL for the OAuth web flow

@latest Build Status Greenkeeper

See GitHub’s Developer Guide for the OAuth web application flow.

Usage

Browsers

<script type="module">
  import { oauthLoginUrl } from 'https://unpkg.com/@octokit/oauth-login-url';

  // get login URL
  const { url } = oauthLoginUrl({
    clientId: '1234567890abcdef1234'
  })

  // redirect to login page
  location.href = url
</script>

Node

const { oauthLoginUrl } = require('@octokit/oauth-login-url')
// or: import { oauthLoginUrl } from '@octokit/oauth-login-url'

// get login URL
const { url } = oauthLoginUrl({
  clientId: '1234567890abcdef1234'
})

// do something with the url :)

Full usage example

const { 
  url,
  clientId,
  redirectUri,  
  login,
  scopes,
  state
} = oauthLoginUrl({
  clientId: '1234567890abcdef1234',
  redirectUri: 'https://example.com',
  login: 'octocat',
  scopes: ['repo', 'admin:org'],
  state: 'secret123',
  log: {
    warn (message) {
      myLogger.log(message, { level: 'warn' })
    }
  }
})

Override or set default options

const myLogin = login.defaults({
  baseUrl: 'https://github.my-enterprise.com',
  defaultRedirectUri: 'https://app.my-enterprise.com',
  client: '1234567890abcdef1234'
})

location.href = oauthLoginUrl().url

Options

Result

oauthLoginUrl() returns an object with the following properties

License

MIT

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago