Step 1: Getting Your API Credentials
Before you can authenticate, you must register your application to receive a uniqueClient ID and Client Secret.
- Go to the iON Developer Portal.
- Log in with your iON account.
- Click Create New Application and enter your
redirect_uri(callback URL). - Copy your
Client IDandClient Secret. Store your secret securely in your backend.
Step 2: Redirect the User to the Authorize Endpoint
Construct a URL and redirect the user’s browser to it. This will show them the iON login screen.GET https://auth.ionelectricity.com/oauth2/authorize
Query Parameters:
response_type:codeclient_id:YOUR_CLIENT_IDredirect_uri: The URL in your application where the user should be sent after logging in.scope:openid profile email
Step 3: Exchange the Code for an ID Token
After the user logs in, they are redirected back to yourredirect_uri with a temporary code in the URL parameters. Your backend server must exchange this code for an id_token.
Important: You must use Basic Authentication by Base64-encoding your ClientID:ClientSecret.
Node.js
id_token as a Bearer token in the Authorization header to read data from the iON API.