(* [CONTEXT] Trying to access box.com for file storage (in interactive console app) Concept could be used for other OAuth providers Box.com has the following info: To complete an OAuth 2.0 flow the following steps need to be completed. 1. Configure the Box SDK 2. Redirect the user to the Box website (with REDIRECT_URI) 3. The user grants the application access 4. Exchange the authorization code for an access token Step 4: "The user is redirected to your application's redirect URL with a query parameter containing a short-lived authorization code." Needed to receive that request to exchange the code So have the console app create a 'webserver' and capture code [this script]. *) open System open System.Net let host = "http://localhost:8888/" let hl = new HttpListener() hl.Prefixes.Add host hl.Start() printfn "Listening for HTTP on %s ..." host // Note: The GetContext method blocks while waiting for a request. let context = hl.GetContext() ///incoming request let request = context.Request ///querystring code key for OAuth2 let code = request.QueryString.["code"] //printfn "Url.OriginalString: %O" request.Url.OriginalString //printfn "RawUrl: %O" request.RawUrl //printfn "%s" code // Obtain a response object to make outgoing response. //Already have what is needed (querystring code) //the response lets the sending server know I got it let response = context.Response let responseString = """