Browse Source

ref: Remove examples (#39210)

Evan Purkhiser 2 years ago
parent
commit
310a492bc6

+ 0 - 1
.eslintignore

@@ -2,7 +2,6 @@
 **/vendor/**/*
 **/tests/**/lang/javascript/fixtures/**/*
 **/tests/**/lang/javascript/example-project/**/*
-/examples/
 /scripts/
 !.github
 !.github/workflows/scripts/*

+ 0 - 10
examples/README.md

@@ -1,10 +0,0 @@
-## Webserver
-
-1. Setup an API application
-2. Add ``http://127.0.0.1:5000/authorized`` as an Authorized Redirect URI
-3. Launch the service:
-
-    BASE_URL=http://dev.getsentry.net:8000 \
-    CLIENT_ID=XXX \
-    CLIENT_SECRET=XXX \
-    python app.py

+ 0 - 2
examples/oauth2_consumer_implicit/.gitignore

@@ -1,2 +0,0 @@
-node_modules
-dist

+ 0 - 8
examples/oauth2_consumer_implicit/index.html

@@ -1,8 +0,0 @@
-<html>
-  <head>
-    <title>oauth2 client example</title>
-  </head>
-  <body>
-    <script src="dist/bundle.js"></script>
-  </body>
-</html>

+ 0 - 10
examples/oauth2_consumer_implicit/index.js

@@ -1,10 +0,0 @@
-import authorize from 'oauth2-implicit'
-
-const credentials = authorize({
-  auth_uri: 'http://dev.getsentry.net:8000/oauth/authorize',
-  client_id: '49ebdc3013aa4ac08c7e811201b3a0ac36bf8fe3bcb648cf976ed57a320bbd68',
-  scope: ['project:releases', 'event:read', 'org:read', 'org:write'],
-  state: {
-    location: window.location
-  },
-});

+ 0 - 22
examples/oauth2_consumer_implicit/package.json

@@ -1,22 +0,0 @@
-{
-  "name": "oauth2_consumer_implicit",
-  "version": "1.0.0",
-  "description": "",
-  "main": "index.js",
-  "scripts": {
-    "test": "echo \"Error: no test specified\" && exit 1",
-    "build": "webpack",
-    "prestart": "webpack",
-    "start": "http-server"
-  },
-  "author": "David Cramer <dcramer@gmail.com> (https://github.com/dcramer)",
-  "license": "ISC",
-  "dependencies": {
-    "babel-core": "^6.23.1",
-    "babel-loader": "^6.3.2",
-    "babel-preset-env": "^1.2.0",
-    "http-server": "^0.9.0",
-    "oauth2-implicit": "^0.7.0",
-    "webpack": "^2.2.1"
-  }
-}

+ 0 - 21
examples/oauth2_consumer_implicit/webpack.config.js

@@ -1,21 +0,0 @@
-var path = require('path');
-
-module.exports = {
-  entry: './index.js',
-  module: {
-    loaders: [
-      {
-        test: /\.js$/,
-        exclude: /(node_modules|bower_components)/,
-        loader: 'babel-loader',
-        query: {
-          presets: ['env']
-        }
-      }
-    ]
-  },
-  output: {
-    filename: 'bundle.js',
-    path: path.resolve(__dirname, 'dist')
-  }
-};

+ 0 - 1
examples/oauth2_consumer_webserver/.gitignore

@@ -1 +0,0 @@
-.env

+ 0 - 97
examples/oauth2_consumer_webserver/app.py

@@ -1,97 +0,0 @@
-import json  # noqa
-import os
-
-import markupsafe
-from flask import Flask, redirect, request, session, url_for
-from flask_oauth import OAuth
-
-BASE_URL = os.environ.get("BASE_URL", "http://dev.getsentry.net:8000")
-CLIENT_ID = os.environ.get("CLIENT_ID")
-CLIENT_SECRET = os.environ.get("CLIENT_SECRET")
-REDIRECT_URI = "/authorized"
-
-SECRET_KEY = "development key"
-DEBUG = True
-
-app = Flask(__name__)
-app.debug = DEBUG
-app.secret_key = SECRET_KEY
-oauth = OAuth()
-
-sentry = oauth.remote_app(
-    "sentry",
-    base_url=BASE_URL,
-    authorize_url=f"{BASE_URL}/oauth/authorize/",
-    request_token_url=None,
-    request_token_params={
-        "scope": "project:releases event:read org:read org:write",
-        "response_type": "code",
-    },
-    access_token_url=f"{BASE_URL}/oauth/token/",
-    access_token_method="POST",
-    access_token_params={"grant_type": "authorization_code"},
-    consumer_key=CLIENT_ID,
-    consumer_secret=CLIENT_SECRET,
-)
-
-
-@app.route("/")
-def index():
-    access_token = session.get("access_token")
-    if access_token is None:
-        return ("<h1>Who are you?</h1>" '<p><a href="{}">Login with Sentry</a></p>').format(
-            url_for("login")
-        )
-
-    from urllib.error import HTTPError, URLError
-    from urllib.request import Request, urlopen
-
-    headers = {"Authorization": f"Bearer {access_token}"}
-    req = Request(f"{BASE_URL}/api/0/organizations/", None, headers)
-    try:
-        res = urlopen(req)
-    except HTTPError as e:
-        if e.code == 401:
-            # Unauthorized - bad token
-            session.pop("access_token", None)
-            return redirect(url_for("login"))
-        return markupsafe.Markup("{}\n{}").format(e.code, e.reason)
-    except URLError as e:
-        return markupsafe.Markup("{}").format(e)
-
-    return markupsafe.Markup("<h1>Hi, {}!</h1>" "<pre>{}</pre>").format(
-        json.loads(session["user"])["email"], json.dumps(json.loads(res.read()), indent=2)
-    )
-
-
-@app.route("/login")
-def login():
-    callback = url_for("authorized", _external=True)
-    return sentry.authorize(callback=callback)
-
-
-@app.route(REDIRECT_URI)
-@sentry.authorized_handler
-def authorized(resp):
-    if "error" in request.args:
-        return markupsafe.Markup(
-            "<h1>Error</h1>" "<p>{}</p>" '<p><a href="{}">Try again</a></p>'
-        ).format(request.args["error"], url_for("login"))
-
-    access_token = resp["access_token"]
-    session["access_token"] = access_token
-    session["user"] = json.dumps(resp["user"])
-    return redirect(url_for("index"))
-
-
-@sentry.tokengetter
-def get_access_token():
-    return session.get("access_token")
-
-
-def main():
-    app.run()
-
-
-if __name__ == "__main__":
-    main()

+ 0 - 2
examples/oauth2_consumer_webserver/requirements.txt

@@ -1,2 +0,0 @@
-flask
-flask-oauth