🔃API Documentation
We have recently launched our MVP of Hylo APIs that can be used by partners to interact with Hylo from third party apps. Currently you have to contact us at hello@hylo.com if you want access to the APIs. We will send you a client_id
and client_secret
manually. We are using the oAuth 2.0 and OpenID Connect standards to enable our API access. We primarily support the oAuth 2.0 Authorization Code flow for full API access in most app types, including web apps and natively installed apps. This requires redirecting to Hylo to get permission from a user to access Hylo as them. We also support the Client Credentials flow/grant type for server-to-server interactions that don't require interaction with a user. This allows a web service to use its own credentials, instead of impersonating a user, to authenticate when calling our APIs. We only support limited API calls for this type of connection.
Authorization Code flow instructions
For full API access in most app types, including web apps and natively installed apps.
Authentication
When asking us to give you a client ID and secret key you will also need to send us a list of possible redirect URLs you might use. Then follow the standard oAuth Authorization Code flow, with the following URLs:
Authorization URL: https://hylo.com/noo/oauth/auth
Access Token URL: https://hylo.com/noo/oauth/token
First make a GET request to the Hylo Authorization URL, this is often done in a popup window, where the user will be asked to give consent to your app accessing their Hylo data.
URL parameters are:
client_id
: the client ID given to you by usredirect_uri
: the URL to redirect to after authorization, must match exactly one of the redirect URIs you sent to us when asking for API accessresponse_type
:code
state
(optional): should be a randomly generated string, used to prevent XSRF attacks by making sure that the state string we send back to you is the same one you sent us.code_challenge
: required for PKCE (Proof Key for Code Exchange). Instructions for generating here: https://www.valentinog.com/blog/challenge/. We generally require PKCE, but if for some reason your system cannot work with that let us know and we can turn it off for your client.
code_challenge_method
: S256 (meaning SHA256)scope
: space separated list of scopes, detailing what information (claims) you are requesting on the behalf of the user. Options are:openid
: required. indicates that the application intends to use OIDC to verify the user's identity. will return a 'sub' claim which is the user IDprofile
: Returns claims that represent basic profile information for the user, including 'name', 'picture', 'updated_at', and 'website'address
: Returns the user's physical address if set.email
: returns the user's contact email if setphone
: returns the user's contact phone number if setoffline_access
: should be used by applications that intend to make additional requests on behalf of the user over time, by enabling requesting of refresh tokens.
prompt
(optional): set to 'consent' to always show the consent screen even if the user has already given permission to your app in the past.Example Authorization request:
https://hylo.com/noo/oauth/auth?client_id=CLIENT_ID&redirect_uri=AFTER_LOGIN_REDIRECT_URI&response_type=code&state=xxzxn7h87h87h&code_challenge=wrU4wFWi_3urf1Kg--e-7WuPm5fOqyao1oGt9Tfz6iM&code_challenge_method=S256&scope=openid%20email&prompt=consent
You will receive a response at the redirect_uri that looks like:
https://uri.com/redirect?state=xxzxn7h87h87h&code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp7&scope=openid%20email
If you passed in a state parameter your app should confirm that the state returned from the authorization call matches the state you passed to us.
Exchange the code received above for an access token by making a request to the Access Token URL.
URL parameters:
code
: The authorization code that is returned from the initial request.client_id
: the client ID given to you by usclient_secret
: the client_secret given to you by usredirect_uri
: the URL to redirect to with the access token, must match exactly one of the redirect URIs you sent to us when asking for API accessgrant_type
:authorization_code
Example access token request:
A Successful response will contain these fields in a JSON array:
access_token
: A token that can be used to access the Hylo API.expires_in
: The remaining lifetime of the access token in seconds.id_token
: A JWT that contains identity information about the user.scope
: The scopes of access granted by the access_token expressed as a list of space-delimited, case-sensitive strings.token_type
: Identifies the type of token returned.refresh_token
(optional): This field is only present if the scope parameters included offline_access in the authentication request. This can be used to request a new access token when this one expires
Making an API call with the access token:
This is a GraphQL based endpoint so you will want to pass in raw POST data in the body.
Example GraphQL query: Querying a Group
NOTE: you will want to pass either a slug or an id to query by. If you pass both only the slug will be used to lookup the group.
Example GraphQL mutation: Updating a Group (only will succeed on groups that the user is a moderator of)
Full GraphQL schema information can be found here: https://github.com/Hylozoic/hylo-node/blob/dev/api/graphql/schema.graphql
Client Credentials instructions
For direct server-server to API calls, without user interaction. Here we offer a more limited set of API calls, but with some special abilities.
Authentication
Before making any API calls you must get an auth token
POST to https://hylo.com/noo/oauth/token
Headers:
Parameters (all required):
grant_type
=client_credentials
client_id
= YOUR_IDclient_secret
= YOUR_SECRETresource
= the server URL you are making the call to (e.g. https://hylo.com, https://staging.hylo.com, or https://localhost:3000)scope
=api:write
if you want to write data, orapi:read
if you just want to read it.
This call will return an ACCESS_TOKEN for use in later API calls. This token will expire in 2 hours at which point you will need to make another API call to get a new ACCESS_TOKEN.
For every subsequent API you will need to authorize by passing this token as Bearer Token in the Authorization Header: Authorization: Bearer ACCESS_TOKEN
Create a User
POST to https://hylo.com/noo/user
Headers:
Parameters:
name
(required) = Judy Mangroveemail
(required) = email@email.comgroupId
(optional) = the id of a group to add the user toisModerator
(optional) = true to add the user to the group specified by groupId as a moderator
Return value:
On success this will return a JSON object that looks like:
If there is already a user with this email but they are a not member of the group, this call will send them an invitation to join the group. You will receive: { message: "User already exists, invite sent to group GROUP_NAME" }
If there is already a user with this email and they are already a member of the group: { message: "User already exists, and is already a member of this group" }
If there is already a user with this email and you didn't pass in a group you will receive: { message: "User already exists" }
Create a Group
POST to https://hylo.com/noo/graphql
Headers:
This is a GraphQL based endpoint so you will want the pass in a raw POST data Example GraphQL mutation:
Update a Group
POST to https://hylo.com/noo/graphql
Headers:
This is a GraphQL based endpoint so you will want the pass in a raw POST data Example GraphQL mutation:
Add a Person to a Group
POST to https://hylo.com/noo/graphql
Headers:
This is a GraphQL based endpoint so you will want the pass in a raw POST data Example GraphQL mutation:
Query a Group
POST to https://hylo.com/noo/graphql
Headers:
This is a GraphQL based endpoint so you will want the pass in a raw POST data Example GraphQL query: NOTE: you will want to pass either a slug or an id to query by. If you pass both only the slug will be used to lookup the group.
Query a Person
POST to https://hylo.com/noo/graphql
Headers:
This is a GraphQL based endpoint so you will want the pass in a raw POST data Example GraphQL query: NOTE: you will want to pass either an email or an id to query by. If you pass both only the id will be used to lookup the person.
Last updated