Google Extension and Asana

Hello All. I create new extension for Google Chrome how can create strict description task. But i faced with problem authorization. I not have domains for Redirect and App Url. How I can authorize user from Google Extension? Thanks!

Rather than doing your own authentication, why don’t you just grab the user’s current authentication cookie from the browser; this is what the original Asana Chrome extension is doing:

1 Like

It’s some help for me, I can get data for self user, but i can’t create task (Send post request) their told me what i’m not authorized. Maybe I’m doing something wrong?

I would take a look at the complete code for the Chrome extension I linked to - it has the capability to add a task so that means it’s doing the same thing you’re trying to do.

When I send POST request, i get error 401, when I not authorized. If I send GET request, I’m get data about me.
I can use asana extension code and remake under self, but I want get understand how it works. Thanks.

Here is my example code:
// manifest.json
{
“manifest_version”: 2,
“version”: “0.0.1”,
“name”: “Create Ticket App”,
“description”: “Create ticket for asana”,
“author” : “Vladislav”,
“browser_action”: {
“default_popup”: “index_popup.html”
},
“permissions”: [
“cookies”,
“storage”,
“identity”,
://.asana.com/*”
],
“icons”: {
“16”: “./images/16x16.png”,
“24”: “./images/24x24.png”,
“48”: “./images/48x48.png”,
“64”: “./images/64x64.png”,
“128”: “./images/128x128.png”
},
“content_security_policy”: “script-src ‘self’ https://app.asana.com; object-src ‘self’”
}

$(document).ready(function () {

getUser();

$('.simple-btn').on('click', function (e) {
    getUser();
});

$('.create-task').on('click', function (e) {
    e.preventDefault();

    console.log(chrome.cookies.get({'url': 'https://app.asana.com', 'name': 'ticket'}, function (cookie) {
            console.log(cookie);
        })
    );

    $.post({
        url:     'https://app.asana.com/api/1.0/tasks/',
        data:    {
            workspace: 0,
            assignee:  0,
            name:      'hello world',
        },
        success: function (response) {
            console.log(response);
        }
    });
});

});

function getUser() {
$.get({
url: ‘https://app.asana.com/api/1.0/users/me’,
success: function (data) {
console.log(data);
// var photo = data.data.photo.image_60x60;
var name = data.data.name;
var email = data.data.email;

        // $('.avatar').css({'background': 'url(' + photo + ')'});
        $('.profile-block > .name').text(name);
        $('.profile-block > .email').text(email);
    },
    dataType: 'JSON',
})

}