Classy's Single Sign On service is a convenient way for people to register and log into your app using their Classy account. Classy's Single Sign On implementation complies with OpenID Connect.
This document describes Classy's implementation of OpenID Connect and the tools made available to 3rd party developers to help them use Classy as an OpenID Identity Provider.
If you are already familiar with OpenID Connect protocol, here is all you need to know to configure Classy as an Identity Provider:
| Endpoint | URL |
|---|---|
| Authorization endpoint | |
| Token endpoint | |
| User info endpoint | |
During this flow:
There are several ways to send the user to the authorization endpoint and to retrieve the authorization code:
The way the authorization code is passed back to your app depends on the method ("redirect", "popup" or "iframe") being used.
When your application needs to authenticate a user, this user shall be redirected to the authorization endpoint. The authorization endpoint URL is of the form:
https://login.classy.org/authorize
?client_id=xxx
&response_type=code
&state=xxx
&redirect_uri=xxx
&scope=xxx
Where:
| Parameter | Requirement | Description |
|---|---|---|
| client_id | Required | The client_id you got when registering your application. |
| response_type | Required | The only OpenID Connect supported response_type by Classy is "code" |
| redirect_uri | Required | URI the user will be redirected to once he authorized your application. It must be equal to one of the redirect_uri you defined when you registered your application. |
| scope | Required | Comma separated list of scope your app is requesting. The "Scope" section of this document details what the available scope are. |
| state | Optional | A string to let your app maintain state between the request and callback. When the user is redirected to your application, the state parameter will be included. You should use this parameter to prevent cross-site request forgery. |
You first need to include the javascript SDK in your page.
Then, just bind the classy-login-btn class to an html element. The single-sign-on popup will be thrown when the user clicks this element. You must also define the function that will handle the authorization code once the user has authorized your application ("authHandler" in our example).
Where:
| Parameter | Requirement | Description |
|---|---|---|
| data-callback | Required | The name of the javascript function that will be called to handle the authorization code. |
| data-scope | Required | Comma separated list of scope your app is requesting. The "Scope" section of this document details what the available scope are. |
| data-flow | Optional |
When the user is sent to the authorize endpoint he must be authenticated on login.classy.org. If this is not the case, the user is redirected to the login form. You can customize this default behavior with this parameter. data-flow can take 3 values:
|
Alternatively, you can also use the Classy.login() method provided by the SDK:
You first need to include the javascript SDK in your page.
Include a container for the iframe in your page with the classy-login-iframe class.
Where:
| Parameter | Requirement | Description |
|---|---|---|
| data-callback | Required | The name of the javascript function that will be called to handle the authorization code. |
| data-scope | Required | Comma separated list of scope your app is requesting. The "Scope" section of this document details what the available scope are. |
| data-flow | Optional |
When the user is sent to the authorize endpoint he must be authenticated on login.classy.org. If this is not the case, the user is redirected to the login form. You can customize this default behavior with this parameter. data-flow can take 3 values:
|
Once the user authorized your app on login.classy.org, an authorization code is generated. The way the authorization code is communicated to your application depends on the SSO method chosen.
Once the user authorized your app, he will be redirected to:
<redirect_uri>?code=xxx&state=xxx
Where:
| Parameter | Description |
|---|---|
| redirect_uri | redirect_uri used to build the authorization endpoint (step 1). |
| code | The authorization code. |
| state | state parameter used to build the authorization endpoint at step 1. Your app must confirm that this parameter received from Classy matches the one created at step 1. |
The authorization code will be passed to the callback method bound to the html element ("authHandler" in our example). This method shall pass this authorization code to your backend server.
Once your backend is in possession of the authorization code, it can be exchanged with an access token:
An access token will be returned:
You can now retrieve the user identity by requesting the GET /2.0/me endpoint using the access token.
which will return a response containing the following data:
Classy is providing a javascript SDK to help you implement the "popup" and the "iframe" methods of the SSO flow.
Just include the following lines in your pages, just before the </body> tag of your html document:
The SDK is asynchronously loaded so that it doesn't block loading other elements of your page. As a result, you must wait for the SDK to be loaded and initialized before using any of its methods:
This method will launch a popup asking a user to authenticate on Classy and authorize (if not already done) your app for the requested scope. The callback function is called with the authorization result.
This method will provide information regarding the login status of the user on login.classy.org.
This method logs the user out of login.classy.org.
If HTML elements having the classy-login-btn or the classy-login-iframe class were added to the
document after the SDK was initialized, they won't be taken into account by the SDK.
This method will let the SDK re-parse the document.
When sending the user to the authorization endpoint, you must define the "scope" of the authorization your app is requesting. A scope is a set of permissions your app is asking a user to grant. It will affect the consent screen the user will see on login.classy.org.
Here is the list of the scope currently made available:
| Name | Description |
|---|---|
| profile deprecated |
|
| read_profile |
|
| write_profile |
|
| read_fundraising_pages |
|
| write_fundraising_pages |
|
| read_fundraising_teams |
|
| write_fundraising_teams |
|
| read_campaigns |
|
| write_campaigns |
|
| read_organizations |
|
| write_organizations |
|
| read_supporters |
|
| write_supporters |
|
| read_transaction_history |
|
| read_transaction_reports |
|
| write_transactions |
|
| write_email |
|
| read_feeds |
|
| write_feeds |
|