Вопрос

I am trying to create a chrome extension. Need to auth with github.

I am currently using oauth.js for auth, using chrome extension boilerplate http://extensionizr.com/

When i try my code at localhost i can auth with no problem.

This is a my code for oauth:

OAuth.initialize('my key');
    OAuth.popup('github', {
        cache: true
    }, function(error, success) {
        console.log(error)
        that.auth_token = success.access_token;
    });

This is popup when i try to auth: popup

This is console error: error

This is Oauth.io domains: enter image description here

This is rquest respose

<!DOCTYPE html>
<html>
    <head>
        <script>
            (function() {
                "use strict";
            var msg="{\"status\":\"error\",\"message\":\"Origin \\\"chrome-extension://bfhbkhhimmcbjgofifofjgbjaojgbihj/\\\" does not match any registered domain/url on oauth.io\",\"state\":\"181DBPf5s84Q6s3rjMJHuiqSlPY\",\"provider\":\"github\"}";
            chrome.runtime.sendMessage("bfhbkhhimmcbjgofifofjgbjaojgbihj", {data:msg});
                window.close();
            })();
            </script>
        </head>
    <body></body>
</html>

Help me!

Это было полезно?

Решение

chrome-extension is not a domain, but a scheme. That's why it doesn't work.

See this answer here: https://github.com/oauth-io/oauthd/issues/52

You need to use

"externally_connectable": {
    "matches": ["https://oauth.io/*"]
},

in the manifest, then chrome.sendMessage will be allowed to execute.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top