Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • a backend service that has an OCN-ready API

  • an OCN - Identity

  • the OCN - Identity of your selected OCN Node and a registration token (TOKEN_A in OCPI Terms)

...

If you are using the Command Line Interface provided in the OCN - Registry Repository on Bitbucket you can simply check the Public URL of your selected OCN Node by doing this:

...

The Public URL could look something like this: https://test-node.emobilify.com

Please visit the OCN - Registry Repository on Bitbucket for further details about this step.

...

Code Block
const express = require("express")
const uuid = require("uuid")

const app = express()

const PUBLIC_URL = "https://service.msp.com"
const TOKEN_B = uuid.v4()
console.log("Auth TOKEN_B = " + TOKEN_B)


const authorize = (req, res, next) => {
	if (req.headers.authorization !== `token`Token ${TOKEN_B}`) {
		return res.status(401).send({
			status_code: 2001,
			status_message: "Unauthorized",
			timestamp: new Date()
		})
	}
	next()
} 


app.get("/ocpi/versions", authorize, async (_, res) => {
	res.send({
		status_code: 1000,
		data: {
			versions: [{
				version: "2.2",
				url: `${PUBLIC_URL}/ocpi/2.2`
			}]
		},
		timestamp: new Date()
	})
})


app.get("/ocpi/2.2", authorize, async (_, res) => {
	res.send({
		status_code: 1000,
		data: {
			version: "2.2",
			endpoints: [
				/* {
					identifier: "locations",
					role: "RECEIVER",
					url: `${PUBLIC_URL}/ocpi/2.2/receiver/locations`
				} */
			]
		},
		timestamp: new Date()
	})
})


app.listen(3000, () => { console.log("Started on port 3000") })

...

Now we are ready to connect to the OCN Node. The credentials request is detailed below. Make sure to replace the variables TOKEN_A, TOKEN_B and PUBLIC_IP, PARTY_ID and COUNTRY_CODE where described. TOKEN_A should match the one generated for you by the faucet. TOKEN_B should match the authorization token that you have created. Meanwhile, PUBLIC_IP should point to your publicly accessible web service. Lastly, PARTY_ID and COUNTRY_CODE refer to the same OCPI credentials that you used when generating the registration token and entering details to the OCN - Registry.

 

Code Block
curl https://test-node.emobilify.com/ocpi/2.2/credentials \
  -H 'Authorization: Token {{TOKEN_A}}' \
  -H 'Content-Type: application/json' \
  -d '{
    "token": "{{TOKEN_B}}",
    "url": "{{PUBLIC_IP}}/ocpi/versions",
    "roles": [{
      "party_id": "{{PARTY_ID}",
      "country_code": "{{COUNTRY_CODE}}",
      "role": "EMSP",
      "business_details": {
        "name": "Tutorial MSP"
      }
    }]
  }'

...