Last active
August 29, 2015 13:56
-
-
Save eugeniop/8818337 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Language="VBScript" %> | |
<script language="JScript" runat="server" src='json2.js'></script> | |
<% | |
CLIENT_ID = "PLACE YOUR AUTH0 CLIENTID HERE" | |
CLIENT_SECRET = "PLACE YOUR AUTH0 CLIENT SECRET HERE" | |
REDIRECT_URI = "http://localhost/Auth0ASP/callback.asp" | |
AUTHORIZATION_CODE = Request.querystring( "code" ) | |
access_token = GetAccessToken(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, AUTHORIZATION_CODE) | |
set profile = GetUserProfile( access_token ) | |
' Do something usefule with the user profile (session, etc), possbily redirect to home | |
Response.Write "UserID = " & profile.user_id | |
Function GetUserProfile(access_token) | |
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP") | |
http.open "GET", "https://eugeniop.auth0.com/userinfo?access_token=" & access_token, False | |
http.send | |
profile = http.responseText | |
Set GetUserProfile = JSON.parse(profile) | |
Set http = Nothing | |
End Function | |
Function GetAccessToken(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI, code) | |
Set http = Server.CreateObject("MSXML2.ServerXMLHTTP") | |
http.open "POST", "https://eugeniop.auth0.com/oauth/token", False | |
http.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" | |
http.send "client_id=" & CLIENT_ID & "&client_secret=" & CLIENT_SECRET & "&redirect_uri=" & server.UrlEncode(REDIRECT_URI) & "&code=" & AUTHORIZATION_CODE & "&grant_type=authorization_code" | |
result = http.responseText | |
Set http = Nothing | |
set jsonResult = JSON.parse(result) | |
GetAccessToken = jsonresult.access_token | |
End Function | |
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Language="VBScript" %><% | |
Option Explicit | |
%> | |
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Testing Auth0 with Classic ASP</title> | |
</head> | |
<body> | |
<script src="https://d19p4zemcycm7a.cloudfront.net/w2/auth0-widget-2.3.min.js"></script> | |
<script type="text/javascript"> | |
var widget = new Auth0Widget({ | |
domain: 'YOUR ACCOUNT IN AUTH0', // eugenio.auth0.com | |
clientID: 'PLACE YOUR AUTH0 CLIENTID HERE', | |
callbackURL: 'http://localhost/Auth0ASP/callback.asp' | |
}); | |
</script> | |
<button onclick="widget.signin()">Login</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Need to note that in case you're using the eu Version of auth0 for classic asp you should change the occurrences of https://eugeniop.auth0.com/ to https://eugeniop.eu.auth0.com !