Reputation: 136
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:
This is console error:
This is Oauth.io domains:
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!
Upvotes: 1
Views: 641
Reputation: 77561
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.
Upvotes: 3