> ## Documentation Index
> Fetch the complete documentation index at: https://docs.streambird.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Github

> Client side **public endpoint** to generate a `redirect_url` for OAuth provider that will direct the user to sign in via Github. User will first sign in to their Github account, Github will then call the MoonKey callback URL set during the setup process for Github provider. Once MoonKey completes the OAuth flow with Github, we will redirect back to the login/signup redirect URLs set for your App with an `internal token` for this session. You can then use this token to verify with our `VerifyOAuthToken` endpoint to retrieve the authenticated user and optionally the original `access_token` and `refresh_token` from Github.
## Query String Example

``` json
/v1/auth/oauth/github/begin?public_token=pk_live_bGcnsYLoObxCSvUcCNBEWgWkOFIBD6JQhx1bMTakf1R6QWrR&redirect=true&login_redirect_url=http://localhost:8080/register

```

## Returns

A successful response returns an object with a `redirect_url` property. If `redirect` query parameter is set to true, a response with status code 302 will be returned, which allows the browser to automatically redirect to the returned `redirect_url` without custom client side redirect logic.



## OpenAPI

````yaml get /v1/auth/oauth/github/begin
openapi: 3.1.0
info:
  title: MoonKey Auth API
  description: >-
    Explore all the details of MoonKey Auth API. All of our APIs are RESTful and
    accept and return JSON.
  version: v1
servers:
  - url: https://api.moonkey.fun
    description: Production
    variables: {}
security:
  - Authorization: []
tags:
  - name: Users
    description: User management API
  - name: Magic Links
    description: ''
  - name: OTPs
    description: >-
      Send OTP (One-time passcodes) by all the supported delivery methods such
      as SMS, email.
  - name: OAuth
    description: ''
  - name: Wallets Login
    description: ''
  - name: Managed Wallets
    description: ''
  - name: Wallet Import
    description: >-
      Import existing wallets into the platform using secure HPKE encryption.
      This flow ensures raw entropy (seed phrases or private keys) never touches
      the server in plaintext.
externalDocs:
  url: ''
  description: ''
paths:
  /v1/auth/oauth/github/begin:
    parameters: []
    get:
      tags:
        - OAuth
      summary: Github
      description: >-
        Client side **public endpoint** to generate a `redirect_url` for OAuth
        provider that will direct the user to sign in via Github. User will
        first sign in to their Github account, Github will then call the MoonKey
        callback URL set during the setup process for Github provider. Once
        MoonKey completes the OAuth flow with Github, we will redirect back to
        the login/signup redirect URLs set for your App with an `internal token`
        for this session. You can then use this token to verify with our
        `VerifyOAuthToken` endpoint to retrieve the authenticated user and
        optionally the original `access_token` and `refresh_token` from Github.

        ## Query String Example


        ``` json

        /v1/auth/oauth/github/begin?public_token=pk_live_bGcnsYLoObxCSvUcCNBEWgWkOFIBD6JQhx1bMTakf1R6QWrR&redirect=true&login_redirect_url=http://localhost:8080/register


        ```


        ## Returns


        A successful response returns an object with a `redirect_url` property.
        If `redirect` query parameter is set to true, a response with status
        code 302 will be returned, which allows the browser to automatically
        redirect to the returned `redirect_url` without custom client side
        redirect logic.
      operationId: BeginGithubOAuth
      parameters:
        - schema:
            type: string
          in: query
          name: public_token
          required: true
          description: >-
            `Required` Public token of the App, public token can be exposed in
            the frontend and client side SDKs.
        - schema:
            type: boolean
          in: query
          name: redirect
          description: >-
            `Optional` Determines if the response should be a 302 auto redirect
            instead of returning the `redirect_url` in the json with a 200
            status code.
        - schema:
            type: string
          in: query
          name: login_redirect_url
          description: >-
            `Optional` If an existing user is found, this URL will be used for
            redirect upon the completion of the OAuth flow
        - schema:
            type: string
          in: query
          name: registration_redirect_url
          description: >-
            `Optional` If a new user is created, this URL will be used for
            redirect upon the completion of the OAuth flow 
      responses:
        '200':
          description: Github response
          content:
            application/json:
              schema:
                description: ''
                type: object
                properties:
                  redirect_url:
                    type: string
                    minLength: 1
                required:
                  - redirect_url
              examples:
                BeginGithubOAuthResp:
                  value:
                    redirect_url: >-
                      https://github.com/login/oauth/authorize?client_id=63a8d0c330e35260c229&redirect_uri=http%3A%2F%2Flocalhost%3A11019%2Fv1%2Fauth%2Foauth%2Fcallback%2Foauthcb_28XPFGcXWv4UvjYYaG74yeZcepx&response_type=code&scope=read%3Auser+user%3Aemail&state=github-jjcHMiUbxPn6hli55B4v5LciXGAPj3dWqNYWTXsQ7xzj1pHhM4rBtrnXnQVSxds1
        '302':
          description: Found
          content:
            application/json:
              schema:
                description: ''
                type: object
                properties:
                  redirect_url:
                    type: string
                    minLength: 1
                required:
                  - redirect_url
              examples:
                BeginGithubOAuthAutoRedirect:
                  value:
                    redirect_url: >-
                      https://github.com/login/oauth/authorize?client_id=63a8d0c330e35260c229&redirect_uri=http%3A%2F%2Flocalhost%3A11019%2Fv1%2Fauth%2Foauth%2Fcallback%2Foauthcb_28XPFGcXWv4UvjYYaG74yeZcepx&response_type=code&scope=read%3Auser+user%3Aemail&state=github-jjcHMiUbxPn6hli55B4v5LciXGAPj3dWqNYWTXsQ7xzj1pHhM4rBtrnXnQVSxds1
          headers:
            Location:
              schema:
                type: string
                example: >-
                  https://github.com/login/oauth/authorize?client_id=63a8d0c330e35260c229&redirect_uri=http%3A%2F%2Flocalhost%3A11019%2Fv1%2Fauth%2Foauth%2Fcallback%2Foauthcb_28XPFGcXWv4UvjYYaG74yeZcepx&response_type=code&scope=read%3Auser+user%3Aemail&state=github-jjcHMiUbxPn6hli55B4v5LciXGAPj3dWqNYWTXsQ7xzj1pHhM4rBtrnXnQVSxds1
      security: []
components:
  securitySchemes:
    Authorization:
      type: http
      scheme: bearer
      description: >-
        Auth Platform API includes all the Auth related features. All Users,
        Phone Numbers, Emails, and OTPs are associated with an `App` as the
        container.


        Endpoints only accept App's `Secret API keys` other than certain
        endpoints that are used client side or via SDK that accept the
        `public_token`.


        ## Authentication using App Api Key


        ## Header:


        ```

        Authorization: Bearer {api_key}

        ```


        ## Authenticated Request


        ```curl

        curl \
          -X GET https://api.moonkey.fun/v1/auth/users/user_24wFP9pDa9YiMJLun94iKykoZs2 \
          -H "Authorization: Bearer sk_test_pRqweh3wvWmJAAVYv7Z0T5iPLzFM4ql0muoyQcjOxGeN3p1r"
        ```

````