customRedirectUri:'https://someUrl.com/custom-redirect'//optional, but allows for deeper customization

}

}

}

};

returnENV;

};

Since torii is really designed to work with 'pop-up' style OAuth, in order to have the login page injected in the iframe on a specific template (i.e. /signin), we need to do a little more work.

Torii has a iframe placeholder component, and this needs to be in the DOM before we can call session.open. So we add it into the signin template

//app/templates/signin.hbs

{{torii-iframe-placeholder}}

But - just adding it won't do anything - we still need a means to open the session after the DOM has been rendered. We do this by adding some code into the route.

//app/routes/signin.js

importEmberfrom'ember';

exportdefaultEmber.Route.extend({

actions:{

//this will fire once the route has fully transitioned

//but the DOM may not be done rendering yet...

didTransition:function(){

//so we schedule it to run afterRender

Ember.run.schedule('afterRender',this,function(){

this.get('session').open('arcgis-oauth-bearer')

.then((authorization)=>{

Ember.debug('AUTH SUCCESS: ', authorization);

//transition to secured route etc...

this.controller.transitionToRoute('secure');

})

.catch((err)=>{

Ember.debug('AUTH ERROR: '+JSON.stringify(err));

});

});

}

}

});

Running the Addon Locally

The torii example app at ArcGIS.com is configured to use
http://torii-example.com:4200/redirect.html as their redirect
uri, so you will need to make an alias in your hosts file that points
torii-example.com to localhost, and you must view the examples from
that same host.

To use the ArcGIS Online authentication you need to run the app on localui.arcgis.com so you should also make an alias for this.

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.