The Notehub authorization API contains endpoints to generate authentication tokens for use with other Notehub API requests.
Name | HTTP Request |
---|---|
Generate OAuth Token | POST /oauth2/token |
Generate Session Token Deprecated | POST /auth/login |
Generate OAuth Token Notehub
Generate an OAuth bearer token that can be used to authenticate subsequent Notehub API requests.
HTTP Method: | POST |
URL: | https://api.notefile.net/oauth2/token |
grant_type
string
This argument must be set to "client_credentials"
.
client_id
string
The Client ID from the Programmatic API access section of a Notehub project. See here for details.
client_secret
string
The Client secret from the Programmatic API access section of a Notehub project. See here for details.
curl -X POST
-L 'https://notehub.io/oauth2/token'
-H 'content-type: application/x-www-form-urlencoded'
-d grant_type=client_credentials
-d client_id=your-client-id
-d client_secret=your-client-secret
Response Members
access_token
string
The string OAuth bearer token. This is the value you’ll want to save for use in subsequent Notehub API requests.
expires_in
int
The number of seconds until the access token expires.
token_type
string
The type of token returned. Currently this will always be set to "bearer"
.
{
"access_token": "abc123...",
"expires_in": 1799,
"token_type": "bearer"
}
Generate Session Token Notehub
This authentication method is officially deprecated in favor of the OAuth workflow documented here.
Generate a session token that can be used to authenticate subsequent Notehub API requests.
HTTP Method: | POST |
URL: | https://api.notefile.net/auth/login |
username
string
The email address of your Notehub account.
password
string
The password of your Notehub account.
If your account was created by using "Sign in with GitHub", by default there is no password available for API authentication purposes. Therefore, you will need to set a password in the Account settings panel in Notehub.io. This password will only be used when generating an authentication token.
curl -X POST
-L 'https://api.notefile.net/auth/login'
-d '{"username":"you@youremail.com", "password": "your_password"}'
import * as NotehubJs from "@blues-inc/notehub-js";
let apiInstance = new NotehubJs.AuthorizationApi();
let loginRequest = {"username":"name@example.com","password":"test-password"}; // LoginRequest |
apiInstance.login(loginRequest).then(
(data) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
},
(error) => {
console.error(error);
}
);
import notehub_py
from notehub_py.models.login200_response import Login200Response
from notehub_py.models.login_request import LoginRequest
from notehub_py.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://api.notefile.net
configuration = notehub_py.Configuration(
host = "https://api.notefile.net"
)
# Enter a context with an instance of the API client
with notehub_py.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = notehub_py.AuthorizationApi(api_client)
login_request = {"username":"name@example.com","password":"test-password"} # LoginRequest |
try:
api_response = api_instance.login(login_request)
print("The response of AuthorizationApi->login:\n")
pprint(api_response)
except Exception as e:
print("Exception when calling AuthorizationApi->login: %s\n" % e)
Response Members
session_token
string
The string session token. You can provide this value to subsequent Notehub API
requests as an X-SESSION-TOKEN
header for authentication.
{
"session_token": "abc123..."
}