Permalink
Browse files

Adding instagram example for 3rd party authentication

  • Loading branch information...
1 parent 2b40c90 commit 9c141a83a3b9b57439c4939eafeff56fb640c9ba @PaulKinlan PaulKinlan committed Dec 3, 2012
@@ -0,0 +1,10 @@
+{
+ "appName": {
+ "message": "Step1",
+ "description": "The name of the application"
+ },
+ "appDescription": {
+ "message": "3rd Party Auth step1",
+ "description": "The description of the application"
+ }
+}
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,30 @@
+<!doctype html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>Step1</title>
+ <!-- build:css styles/app.css -->
+ <link rel="stylesheet" href="styles/main.css">
+ <!-- endbuild -->
+ <script src="index.js"></script>
+ <style>
+ pre {
+overflow-y: scroll;
+overflow-x: hidden;
+position: absolute;
+bottom: 0;
+top: 120px;
+box-shadow: inset 0px 0px 5px black;
+padding: 5px;
+right: 0;
+left: 0;
+ }</style>
+ </head>
+ <body>
+ <h1>Step1</h1>
+ <button id="login">Log in</button>
+ <pre id="output">
+
+ </pre>
+ </body>
+</html>
View
@@ -0,0 +1,37 @@
+onload = function() {
+ var login = document.getElementById("login");
+ var output = document.getElementById("output");
+
+ login.onclick = function() {
+ var identityDetails = {
+ url: "https://instagram.com/oauth/authorize/?client_id=dd49c144e7914b99aca3bc1fa2735b8d&redirect_uri=chrome-extension://gghhbcbhogmipjcfkkondjepmoaobhph/auth.html&response_type=token",
+ interactive: true
+ };
+
+ chrome.experimental.identity.launchWebAuthFlow(identityDetails, function(responseUrl) {
+ console.log(responseUrl);
+ var accessToken = responseUrl.substring(responseUrl.indexOf("=") + 1);
+ console.log(accessToken);
+
+ var api = new InstagramAPI(accessToken);
+ api.request("users/self/feed", undefined, function(data) {
+ console.log(data);
+ output.textContent = JSON.stringify(data, null, 4);
+
+
+ });
+ });
+ };
+};
+
+var InstagramAPI = function(accessToken) {
+ this.request = function(method, arguments, callback) {
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function() {
+ callback(JSON.parse(xhr.response));
+ };
+
+ xhr.open("GET", "https://api.instagram.com/v1/" + method + "?access_token=" + accessToken);
+ xhr.send();
+ };
+}
View
@@ -0,0 +1,12 @@
+/**
+ * Listens for the app launching then creates the window
+ *
+ * @see http://developer.chrome.com/trunk/apps/experimental.app.html
+ * @see http://developer.chrome.com/trunk/apps/app.window.html
+ */
+chrome.app.runtime.onLaunched.addListener(function(intentData) {
+ chrome.app.window.create('index.html', {
+ width: 500,
+ height: 309
+ });
+});
@@ -0,0 +1,18 @@
+{
+ "name": "__MSG_appName__",
+ "version": "1",
+ "manifest_version": 2,
+ "description": "__MSG_appDescription__",
+ "icons": {
+ "16": "icon-16.png",
+ "128": "icon-128.png"
+ },
+ "default_locale": "en",
+ "app": {
+ "background": {
+ "scripts": ["main.js"]
+ }
+ },
+ "key": "UEFVTCBST0NLUw==",
+ "permissions": ["experimental", "identity", "https://api.instagram.com/*"]
+}
@@ -0,0 +1 @@
+/* Will be compiled down to a single stylesheet with your sass files */

0 comments on commit 9c141a8

Please sign in to comment.