---
agentTools:
  projectIndex: https://docs.instamojo.com/llms.txt
---

# Generate Access token (Application Based Authentication)

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "API v2",
    "version": "2"
  },
  "servers": [
    {
      "url": "https://api.instamojo.com"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "apiKey",
        "name": "Authorization",
        "in": "header",
        "x-default": "Bearer {{access_token}}"
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/oauth2/token/": {
      "post": {
        "summary": "Generate Access token (Application Based Authentication)",
        "description": "",
        "operationId": "generate-access-token-application-based-authentication",
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "grant_type",
                  "client_id",
                  "client_secret"
                ],
                "properties": {
                  "grant_type": {
                    "type": "string",
                    "description": "This describes the type of authentication.",
                    "default": "client_credentials"
                  },
                  "client_id": {
                    "type": "string",
                    "description": "The client_id that is provided to you."
                  },
                  "client_secret": {
                    "type": "string",
                    "description": "The client_secret that is provided to you."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n  \"access_token\": \"y70kak2K0Rg7J4PAL8sdW0MutnGJEl\",\n  \"token_type\": \"Bearer\",\n  \"expires_in\": 36000,\n  \"scope\": \"read write\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "access_token": {
                      "type": "string",
                      "example": "y70kak2K0Rg7J4PAL8sdW0MutnGJEl"
                    },
                    "token_type": {
                      "type": "string",
                      "example": "Bearer"
                    },
                    "expires_in": {
                      "type": "integer",
                      "example": 36000,
                      "default": 0
                    },
                    "scope": {
                      "type": "string",
                      "example": "read write"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n  \"error\": \"unsupported_grant_type\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "unsupported_grant_type"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "401",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n  \"error\": \"invalid_client\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "invalid_client"
                    }
                  }
                }
              }
            }
          }
        },
        "deprecated": false,
        "security": [],
        "x-readme": {
          "code-samples": [
            {
              "language": "php",
              "code": "<?php\n\n$ch = curl_init();\ncurl_setopt($ch, CURLOPT_URL, 'https://api.instamojo.com/oauth2/token/');     \ncurl_setopt($ch, CURLOPT_HEADER, FALSE);\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);\ncurl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);\n\n$payload = Array(\n    'grant_type' => 'client_credentials',\n    'client_id' => '21fe14a60057ece6c76496175cb0238a2ffd87be',\n    'client_secret' => '-KWPoDO!_l?MZQ-DsZeQ0TXXcvuDn;mxmAtGho8Xijn=iH6F'\n  );\n\ncurl_setopt($ch, CURLOPT_POST, true);\ncurl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));\n$response = curl_exec($ch);\ncurl_close($ch); \n\necho $response;\n\n?>"
            },
            {
              "language": "python",
              "code": "import requests\nrequests.post('https://api.instamojo.com/oauth2/token/', data={\n    \t'grant_type': 'client_credentials',\n  \t\t'client_id': '21fe14a60057ece6c76496175cb0238a2ffd87be',\n    \t'client_secret': '-KWPoDO!_l?MZQ-DsZeQ0TXXcvuDn;mxmAtGho8Xijn=iH6F'\n})\n              "
            },
            {
              "language": "curl",
              "code": "curl https://api.instamojo.com/oauth2/token/ \\\n  --data \n\"grant_type=client_credentials&client_id=21fe14a60057ece6c76496175cb0238a2ffd87be&client_secret=-KWPoDO!_l?MZQ-DsZeQ0TXXcvuDn;mxmAtGho8Xijn=iH6F\""
            }
          ],
          "samples-languages": [
            "php",
            "python",
            "curl"
          ]
        }
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true,
  "_id": "63053f959807941f67a92cf5:5e4279da383a0a00449c1bc7"
}
```