Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding instagram example for 3rd party authentication

  • Loading branch information...
commit 9c141a83a3b9b57439c4939eafeff56fb640c9ba 1 parent 2b40c90
@PaulKinlan PaulKinlan authored
View
10 instagram-auth/_locales/en/messages.json
@@ -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
BIN  instagram-auth/icon-128.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  instagram-auth/icon-16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
30 instagram-auth/index.html
@@ -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
37 instagram-auth/index.js
@@ -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
12 instagram-auth/main.js
@@ -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
+ });
+});
View
18 instagram-auth/manifest.json
@@ -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/*"]
+}
View
1  instagram-auth/styles/main.css
@@ -0,0 +1 @@
+/* Will be compiled down to a single stylesheet with your sass files */
Please sign in to comment.
Something went wrong with that request. Please try again.