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

# Socialconnection

Social Authentication allows your client to authenticate with social providers. The endpoints are pre-built and are easy for you to manage the social authentication flow from your client application. To get your `{auth_base_url}`, check it out here - [Get started with base url](/authentication/api/generalinfo#get-started-with-base-url).

<Info>
  Note : **Signup and Login** authentication methods are handled under this single endpoint. If the user logging with a provider does not exists, then new user is created or else existing user details are returned as response
</Info>

## Step - 1 : Setup Social Connection

To setup and get `connection_name` of your preferrred social connection, check it our here - [Setup your social connection](/authentication/quickstart/methods/social)

<Note>
  CALLBACK URL

  Make sure to configure the below given call back URL in the third party service `https://authn.zeromagic.cloud/oauth/callback/`
</Note>

## Step - 2 : GET Authorisation Page URL

You will need to redirect the user to preferred social provider page to grant access to your application. You can get this authorize url from the below endpoint. On opening the `authorize_url` link, it will display a page asking the user to approve or deny access to your application. However, if you provide an invalid config credentials or redirect\_uri then the user will instead see an error page.

<Accordion title="Endpoint" defaultOpen="true">
  <ParamField path="POST" type="{auth_base_url}/oauth" />
</Accordion>

<Accordion title="Header">
  <ParamField query="APP-KEY" type="string" required>
    App key of the particular project
  </ParamField>
</Accordion>

<Accordion title="Body Data">
  POST the data in the **application/json** format.

  <ParamField body="connection_name" type="string" required>
    Unique connection\_name of your social method
  </ParamField>
</Accordion>

<Accordion title="Response Body Data">
  <ResponseField name="connection_name" type="string">
    Unique connection\_name of your social method
  </ResponseField>

  <ResponseField name="authorize_url" type="string">
    URL of authorisation consent page
  </ResponseField>
</Accordion>

#### Example

```jsx Request theme={null}
POST https://authn.zeromagic.cloud/auth/353d1499ab5149e194a53cf0f6c837f4/development/oauth 
HTTP/1.1
APP-KEY : ldM6yPAAE3PRTZbHXrjqGGzZY2Yjm7GwjAyjbNqWH48

{
    "connection_name":"google"
}
```

```jsx Response theme={null}
HTTP/1.1 
200 OK

{
    "connection_name":"google",
    "authorize_url":"https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=697287702987-gkvha4hnaucu0bks7p92b3.apps.googleusercontent.com&redirect_uri=http%3A//localhost%3A8000/api/oauth/callback&scope=https://www.googleapis.com/auth/userinfo.email&state=gAAAAABmITpQ_yFqTdppecJMBvXYFwa6lbJyF-DbxIfQ2LbvkEvErkFYQhrrqb_ABxWCXL75VcFGBf2cx010roKZ0VSFj8JHg-X6sieSSguLIoJfHF3l0t1QfA8F57wg4jmjZZEeQ=="
}
```

You can open this `authorize_url` from your client applicantion end and it will be prompted to user consent page.

## Step - 3 : User Success Response

<Note>
  Client Redirect URI

  It is necessary to add your **client application in oauth redirect uri** under project settings. The success response is appended to your client application redirect uri as query params. To add oauth redirect uri, check it our here - [Add OAuth Redirect uri](/authentication/quickstart/methods/social)
</Note>

<Accordion title="Query Params">
  <ParamField query="user_id" type="string">
    User Id of the user
  </ParamField>

  <ParamField query="email" type="string">
    Email address of the user
  </ParamField>

  <ParamField query="access_token" type="string">
    JWT access token is returned
  </ParamField>

  <ParamField query="token_type" type="string">
    Value is *bearer*
  </ParamField>

  <ParamField query="expires_in" type="string">
    Currently no expiry time for token, Returns null
  </ParamField>
</Accordion>

The output response will be in the format of `{client_oauth_redirect_uri}?{success_params}`
For example, if your client\_oauth\_redirect\_uri is **[https://client.zeromagic.cloud/](https://client.zeromagic.cloud/)** then success response will be in the format of

```jsx theme={null}
https://client.zeromagic.cloud/?user_id=&access_token=&token_type=&expires_in=
```

#### Success Response Example

```jsx Success Response theme={null}
GET https://client.zeromagic.cloud/?user_id=1&access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTIzNDU2Nzg5LCJuYW1lIjoiSm9zZXBoIn0.OpOSSw7e485LOP5PrzScxHb7SR6sAOMRckfFwi4rp7o&token_type=bearer&expires_in=null
HTTP/1.1 
```

#### Error Response Example

The error message is also appended to the redirect uri as query params.The error message will be in the format of `https://client.zeromagic.cloud/?error=&message=&code=&state=`

```jsx Error Response theme={null}
GET https://client.zeromagic.cloud/?error=error&message=message&code=error_code&state=gAAAAABmIWikfuZW6M2N5P6aGiL7wZOp1D_wCC2aIP4nlqFmVjS7KhHByd5zJjK_BpFeAc8yj24CDDmCtgC4MV1bATWEKzmkLw%3D%3D
HTTP/1.1 
```

### Support Social Providers

To know about the supported social providers, visit here - [Supported Social Providers](/authentication/quickstart/methods/social#supported-social-providers)
