> ## 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.

# Google

> Client side **public endpoint** to generate a `redirect_url` for OAuth provider that will direct the user to sign in via Google. User will first sign in to their Google account, Google will then call the MoonKey callback URL set during the setup process for Google provider. Once MoonKey completes the OAuth flow with Google, we will redirect back to the login/registration 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 Google.
## Query String Example

``` json
/v1/auth/oauth/google/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/google/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/google/begin:
    parameters: []
    get:
      tags:
        - OAuth
      summary: Google
      description: >-
        Client side **public endpoint** to generate a `redirect_url` for OAuth
        provider that will direct the user to sign in via Google. User will
        first sign in to their Google account, Google will then call the MoonKey
        callback URL set during the setup process for Google provider. Once
        MoonKey completes the OAuth flow with Google, we will redirect back to
        the login/registration 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 Google.

        ## Query String Example


        ``` json

        /v1/auth/oauth/google/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: BeginGoogleOAuth
      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: Google response
          content:
            application/json:
              schema:
                description: ''
                type: object
                properties:
                  redirect_url:
                    type: string
                    minLength: 1
                required:
                  - redirect_url
              examples:
                BeginGoogleOAuthResp:
                  value:
                    redirect_url: >-
                      https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=1008100163226-56ujvvb72rat1rieggmi1kqepqpsjdsn.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A11019%2Fv1%2Foauth%2Fgoogle%2Fcallback&response_type=code&scope=openid+email+profile&state=google-60ZMQkILtQYhb5QiEHIVZ8JUgmI0z54SYEWDWwkge4uZaDoo
        '302':
          description: Found
          content:
            application/json:
              schema:
                description: ''
                type: object
                properties:
                  redirect_url:
                    type: string
                    minLength: 1
                required:
                  - redirect_url
              examples:
                BeginGoogleOAuthAutoRedirect:
                  value:
                    redirect_url: >-
                      https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=1008100163226-56ujvvb72rat1rieggmi1kqepqpsjdsn.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A11019%2Fv1%2Foauth%2Fgoogle%2Fcallback&response_type=code&scope=openid+email+profile&state=google-60ZMQkILtQYhb5QiEHIVZ8JUgmI0z54SYEWDWwkge4uZaDoo
          headers:
            Location:
              schema:
                type: string
                example: >-
                  https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=1008100163226-56ujvvb72rat1rieggmi1kqepqpsjdsn.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A11019%2Fv1%2Foauth%2Fgoogle%2Fcallback&response_type=code&scope=openid+email+profile&state=google-60ZMQkILtQYhb5QiEHIVZ8JUgmI0z54SYEWDWwkge4uZaDoo
      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"
        ```

````