Search code examples
ember.jsember-simple-auth

Ember simple auth add token as query parameter in custom authorizer


How I can do to make the authorizer add the token as a query parameter in my requests to the server?

For example I have a GET to: http://domain/api/resource

And I want the authorizer add the token: http://domain/api/resource?token=TOKEN_DATA


Solution

  • I'm not sure you can do that (by using the authorizer), looking at the documentation and source-code of ember-simple-auth I think you can only set headers not change the url when the authorize method is called.

    If you really need that I think you might to have to do a custom ajax call.

    let content = {}; //Your content
    let session = this.get('session');
    const accessToken = session.get('session.authenticated.token');
    Ember.$.ajax({
        data: JSON.stringify(content),
        dataType: 'json',
        method: 'POST',
        url: `${url}/?token={accessToken}`,
    
    })