WebAPI/MobileIdentity

From MozillaWiki
Jump to: navigation, search

Mobile Identity API

The Mobile Identity WebAPI enables web application authors to obtain a verified phone number (MSISDN) after the user selected the number to be shared and gave explicit permission to the app to obtain it.

DOM API

 dictionary MobileIdOptions {
   boolean forceSelection = false;
 };
 partial interface Navigator {
   Promise getMobileIdAssertion(optional MobileIdOptions options);
 };

The returned Promise will be resolved with a verifiable BrowserId assertion containing the user's phone number as the verifiedMSISDN field or it will be rejected with a DOMError object containing one of the following error strings:

  • OFFLINE
  • DIALOG_CLOSED_BY_USER

Permission model

The API is exposed to Firefox OS privileged and certified applications that should list the mobileid permission in their manifests. The user needs to provide explicit permission to the origin requesting the phone number. This permission is given through the user agent chrome UI and it is remembered per origin by default.

Mobile Identity Firefox OS dialog

Code example

 function _verifyAssertion(aAssertion) {
   // Make use of the remote verification API
   // and return the verified msisdn.
   // NB: This is necessary to make sure that the user *really* controls this phone number!
 }
 
 // Request a mobile identity assertion and force the chrome UI to
 // allow the user to change a possible previous selection.
 navigator.getMobileIdAssertion({ forceSelection: true })
 .then(
   (assertion) => {
     _verifyAssertion(assertion)
     .then(
       (msisdn) => {
         // Do stuff with the msisdn.
       }
     );
   },
   (error) {
     // Process error.
   };
 );

Implementation details

Current status

Implemented and enabled in Firefox OS 2.0 and allowed for certified and privileged apps.

Tracking bugs

bug 1021594

Client

Debugging

To obtain Mobile ID debug messages in the adb logcat you need to set the following preferences:

 user_pref("services.mobileid.loglevel", "Debug");
 user_pref("services.hawk.loglevel", "Debug");
 user_pref("services.hawk.log.sensitive", true); 

You should see debug messages like:

 Gecko  I  1411760725167	MobileId	DEBUG	getMobileIdAssertion

You might also need to change the server url for testing purposes. To do so, you can set the following preference:

 user_pref("services.mobileid.server.uri", "https://msisdn-dev.stage.mozaws.net"); 

Mobile ID verification service

Mobile ID verification service