# easyroam Useragent

# Registering a new easyroam useragent

  • Go to https://auth.easyroam.de/console/applications (make sure that you are logged-in) and click on the
    Create new appplication button.
  • Make sure the useragent application type is selected and the Activate client switch is toggled on.
  • Enter a name for your API client
  • Enter a client uri that resolve to the client making the API calls
  • Enter a redirect uri for your API client
  • Select all scopes your API client is going to use.
  • (Optional) Toggle on the Use client secret switch.

# Client details

After clicking on the Create application button you will receive your client_id and, if you have decided to use one, your client_secret.

  • Your client_id will be displayed every time you visit the application site in the authentication console and will look something like this: 123456.easyroam.auth
  • Your client_secret will only be displayed ONCE! Make sure you save it somewhere safe.

# Authenticating

Once you have your client_id your useragent can authenticate users that decide to use it.

Minimal authentication is achived by redirecting the user to the authentication url:

GET https://auth.easyroam.de/oauth/authorize?response_type=code&client_id=<your_client_id>&redirect_uri=<your_redirect_uri>&scope=<your_scopes>

After the user has authenticated himself and has approved the scopes your API client is requesting he will be redirected to your redirect uri with the code and, if you have sent one, the state parameter. You can then exchange your authorization code for an access_token, refresh_token and id_token by submitting an HTTP form:

POST https://auth.easyroam.de/oauth/token
grant_type=authorization_code
client_id=<your_client_id>
code=<your_authorization_code>
redirect_uri=<your_redirect_uri>

Upon successful authentication you will receive a Json object containing 5 properties like so:

{
    "access_token": "...",
    "id_token": "...",
    "refresh_token": "...",
    "token_type": "Bearer",
    "code": "..."
}
import requests 

params = {
    "grant_type": "authorization_code",
    "client_id": "<your_client_id>",
    "code": "<your_authorization_code>",
    "redirect_uri": "<your_redirect_uri>"
}
r = requests.post(
    "https://auth.easyroam.de/oauth/token",
    data=params
)
r_json = r.json()
access_token = r_json["access_token"]
id_token = r_json["id_token"]
refresh_token = r_json["refresh_token"]

print(access_token)
print(id_token)
print(refresh_token)
const axios = require('axios');

const creds = {
    "grant_type": "authorization_code",
    "client_id": "<your_client_id>",
    "code": "<your_authorization_code>",
    "redirect_uri": "<your_redirect_uri>"
};

const resp = await axios({
    method: 'POST',
    url: `https://auth.easyroam.de/oauth/token`,
    data: creds
});

const { access_token, refresh_token, id_token } = resp.data;
console.log(access_token);
console.log(id_token);
console.log(refresh_token);

For a more complex example check out our example easyroam useragent.

# Refreshing an access token

Access tokens are valid for 30 minutes. After that you need to refresh them using the refresh_token you received during authentication:

POST https://auth.easyroam.de/oauth/token
grant_type=refresh_token
client_id=<your_client_id>
refresh_token=<your_refresh_token>

Upon successful refresh you will receive a Json object containing 3 properties like so:

{
    "access_token": "...",
    "id_token": "...",
    "token_type": "Bearer"
}
import requests 

params = {
    "grant_type": "refresh_token",
    "client_id": "<your_client_id>",
    "refresh_token": "<your_refresh_token>"
}
r = requests.post(
    "https://auth.easyroam.de/oauth/token",
    data=params
)
r_json = r.json()
access_token = r_json["access_token"]
id_token = r_json["id_token"]

print(access_token)
print(id_token)
const axios = require('axios');

const creds = {
    "grant_type": "refresh_token",
    "client_id": "<your_client_id>",
    "refresh_token": "<your_refresh_token>"
};

const resp = await axios({
    method: 'POST',
    url: `https://auth.easyroam.de/oauth/token`,
    data: creds
});

const { access_token, id_token } = resp.data;
console.log(access_token);
console.log(id_token);

# Logout

To log out a user you can simply redirect him to the logout url with the id_token parameter set to the id_token you received during authentication, your client_id and your logout_uri:

GET https://auth.easyroam.de/oauth/logout?id_token=<your_id_token>&client_id=<your_client_id>&logout_uri=<your_logout_uri>

This will automatically delete the active session associated with the id_token and redirect the user to your logout_uri.