Neucron
Search
K
Comment on page

OAuth

OAuth Authorization

Overview

This documentation provides detailed information about the /oauth/authorize endpoint, which is a crucial step in the OAuth 2.0 authorization flow. This endpoint allows Neucron to initiate the authorization process for your app. After a successful user authorization, your app will receive an authorization code, which can then be used to obtain an access token by calling the /oauth/token endpoint.

Endpoint Details

  • HTTP Method: POST
  • Security: Bearer Token Authentication

Request

The request body should include the following parameters as a JSON object:
  • token (object, required): An object containing the authorization request parameters, including:
    • app_id (string): The unique identifier of your app.
    • app_key (string): The app's secret key.
    • state (string): A random string to prevent cross-site request forgery (CSRF) attacks.
    • redirect_uri (string): The URI where Neucron will redirect the user after authorization.
    • permissions (string, comma-separated): The list of permissions your app is requesting from the user.
Example Request Body:
{
"token": {
"app_id": "YourAppID",
"app_key": "YourAppKey",
"state": "RandomString",
"redirect_uri": "https://yourapp.com/oauth/callback",
"permissions": "read_profile,write_data"
}
}

Response

The endpoint returns the following responses:
  • 200 OK: The authorization request was successful.
    Response Body (JSON):
    {
    "data": {
    "code": "AuthorizationCode",
    "user_id": "UserID"
    },
    "status_code": 200
    }
    • code (string): The authorization code generated for the user.
    • user_id (string): The unique identifier of the user.
  • 400 Bad Request: An error occurred due to a client request issue.
    Response Body (JSON):
    {
    // Error details, reference the #/definitions/errorhandler.ClientError schema
    }
  • 401 Unauthorized: The request is unauthorized. Ensure that the provided app_id and app_key are valid.
    Response Body (JSON):
    {
    // Error details, reference the #/definitions/errorhandler.ClientError schema
    }
  • 500 Internal Server Error: An internal server error occurred.
    Response Body (JSON):
    {
    // Error details, reference the #/definitions/errorhandler.ClientError schema
    }

Example Usage

Request:
POST /oauth/authorize
Host: neucron.io
Authorization: Bearer YourAccessToken
Content-Type: application/json
{
"token": {
"app_id": "YourAppID",
"app_key": "YourAppKey",
"state": "RandomString",
"redirect_uri": "https://yourapp.com/oauth/callback",
"permissions": "read_profile,write_data"
}
}
Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": {
"code": "AuthorizationCode",
"user_id": "UserID"
},
"status_code": 200
}

Definitions

usermodel.AuthorizeRequest

This is a reference to the schema defining the parameters required for the authorization request. Please refer to the schema documentation for specific details.

errorhandler.ClientError

This is a reference to the schema defining client error responses. Please refer to the schema documentation for specific details.

Tags

  • OAuth: Use this tag to categorize operations related to OAuth 2.0 authorization.

Summary

The /oauth/authorize endpoint plays a critical role in the OAuth 2.0 authorization flow, allowing Neucron to initiate user authorization for your app. After successful authorization, your app will receive an authorization code, which is a key step in obtaining an access token. Ensure that you provide valid authorization parameters in the request body for a smooth authorization process. If there are any issues, the endpoint will return appropriate error responses for further diagnosis.
If you need more information about specific schemas or have any questions, please refer to the corresponding documentation or contact the API support team.
Oops, something is missing.We could not find the original source to display this content.

OAuth Permissions Grant

Overview

This documentation provides detailed information about the /oauth/permissions/grant endpoint, which is a part of the OAuth 2.0 authorization flow. This endpoint allows Neucron to request additional permissions from a user for your app. After the user grants these new permissions, your app can obtain a new access token by repeating the authorization flow from the /oauth/authorize endpoint.

Endpoint Details

  • HTTP Method: PATCH
  • Security: Bearer Token Authentication

Request

The request body should include the following parameter:
  • permissions (object, required): An object containing the permission request details, including:
    • app_id (string): The unique identifier of your app.
    • app_key (string): The app's secret key.
    • state (string): A random string to prevent cross-site request forgery (CSRF) attacks.
    • redirect_uri (string): The URI where Neucron will redirect the user after granting permissions.
    • permissions (string, comma-separated): The list of additional permissions your app is requesting from the user.
Example Request Body:
{
"permissions": {
"app_id": "YourAppID",
"app_key": "YourAppKey",
"state": "RandomString",
"redirect_uri": "https://yourapp.com/oauth/permissions/callback",
"permissions": "write_data,manage_notifications"
}
}

Response

The endpoint returns the following responses:
  • 200 OK: The permission request was successful, and the user granted the new permissions.
    Response Body (JSON):
    {
    "data": {
    "message": "Permissions granted successfully."
    },
    "status_code": 200
    }
  • 400 Bad Request: An error occurred due to a client request issue.
    Response Body (JSON):
    {
    // Error details, reference the #/definitions/errorhandler.ClientError schema
    }
  • 401 Unauthorized: The request is unauthorized. Ensure that the provided app_id and app_key are valid.
    Response Body (JSON):
    {
    // Error details, reference the #/definitions/errorhandler.ClientError schema
    }
  • 500 Internal Server Error: An internal server error occurred.
    Response Body (JSON):
    {
    // Error details, reference the #/definitions/errorhandler.ClientError schema
    }

Example Usage

Request:
PATCH /oauth/permissions/grant
Host: neucron.io
Authorization: Bearer YourAccessToken
Content-Type: application/json
{
"permissions": {
"app_id": "YourAppID",
"app_key": "YourAppKey",
"state": "RandomString",
"redirect_uri": "https://yourapp.com/oauth/permissions/callback",
"permissions": "write_data,manage_notifications"
}
}
Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": {
"message": "Permissions granted successfully."
},
"status_code": 200
}

Definitions

usermodel.GrantNewPermsReq

This is a reference to the schema defining the parameters required for the permission grant request. Please refer to the schema documentation for specific details.

errorhandler.ClientError

This is a reference to the schema defining client error responses. Please refer to the schema documentation for specific details.

Tags

  • OAuth: Use this tag to categorize operations related to OAuth 2.0 authorization.

Summary

The /oauth/permissions/grant endpoint is a crucial part of the OAuth 2.0 authorization flow, allowing Neucron to request additional permissions from a user for your app. After the user grants these new permissions, your app can obtain a new access token by repeating the authorization flow from the /oauth/authorize endpoint. Ensure that you provide valid permission request parameters in the request body for a smooth permissions grant process. If there are any issues, the endpoint will return appropriate error responses for further diagnosis.
If you need more information about specific schemas or have any questions, please refer to the corresponding documentation or contact the API support team.
Oops, something is missing.We could not find the original source to display this content.

OAuth Token

Overview

This documentation provides detailed information about the /oauth/token endpoint, which is a critical step in the OAuth 2.0 authorization flow. This endpoint allows users, clients, or apps to exchange an authorization code, key ID, and key secret for a JWT (JSON Web Token) access token.

Endpoint Details

  • HTTP Method: POST

Request

The request body should include the following parameter:
  • token (object, required): An object containing the parameters required to obtain an access token, including:
    • auth_code (string): The authorization code obtained from the /oauth/authorize or /oauth/permissions/grant process.
    • key_id (string): The key ID associated with the app or client.
    • key_secret (string): The secret key associated with the app or client.
Example Request Body:
{
"token": {
"auth_code": "AuthorizationCode",
"key_id": "YourKeyID",
"key_secret": "YourKeySecret"
}
}

Response

The endpoint returns the following responses:
  • 200 OK: The access token was successfully generated.
    Response Body (JSON):
    {
    "data": {
    "access_token": "JWTAccessToken"
    },
    "status_code": 200
    }
    • access_token (string): The JWT access token that can be used for authenticated requests.
  • 400 Bad Request: An error occurred due to an invalid request body.
    Response Body (JSON):
    {
    // Error details, reference the #/definitions/errorhandler.ClientError schema
    }
  • 401 Unauthorized: The request is unauthorized. Ensure that the provided auth_code, key_id, and key_secret are valid.
    Response Body (JSON):
    {
    // Error details, reference the #/definitions/errorhandler.ClientError schema
    }
  • 500 Internal Server Error: An internal server error occurred.
    Response Body (JSON):
    {
    // Error details, reference the #/definitions/errorhandler.ClientError schema
    }

Example Usage

Request:
POST /oauth/token
Host: example.com
Content-Type: application/json
{
"token": {
"auth_code": "AuthorizationCode",
"key_id": "YourKeyID",
"key_secret": "YourKeySecret"
}
}
Response:
HTTP/1.1 200 OK
Content-Type: application/json
{
"data": {
"access_token": "JWTAccessToken"
},
"status_code": 200
}

Definitions

usermodel.OauthTokenReq

This is a reference to the schema defining the parameters required to obtain an access token. Please refer to the schema documentation for specific details.

errorhandler.ClientError

This is a reference to the schema defining client error responses. Please refer to the schema documentation for specific details.

Tags

  • OAuth: Use this tag to categorize operations related to OAuth 2.0 authentication.

Summary

The /oauth/token endpoint is a critical step in the OAuth 2.0 authorization flow, allowing users, clients, or apps to exchange an authorization code, key ID, and key secret for a JWT access token. Ensure that you provide valid parameters in the request body to obtain a successful access token. If there are any issues, the endpoint will return appropriate error responses for further diagnosis.
If you need more information about specific schemas or have any questions, please refer to the corresponding documentation or contact the API support team.
Oops, something is missing.We could not find the original source to display this content.
Last modified 3mo ago