LEFT | RIGHT |
1 /* | 1 /* |
2 Copyright 2013 Google Inc | 2 Copyright 2013 Google Inc |
3 | 3 |
4 Licensed under the Apache License, Version 2.0 (the "License"); | 4 Licensed under the Apache License, Version 2.0 (the "License"); |
5 you may not use this file except in compliance with the License. | 5 you may not use this file except in compliance with the License. |
6 You may obtain a copy of the License at | 6 You may obtain a copy of the License at |
7 | 7 |
8 http://www.apache.org/licenses/LICENSE-2.0 | 8 http://www.apache.org/licenses/LICENSE-2.0 |
9 | 9 |
10 Unless required by applicable law or agreed to in writing, software | 10 Unless required by applicable law or agreed to in writing, software |
(...skipping 22 matching lines...) Expand all Loading... |
33 /// OAuth 2.0 verification code receiver that runs a local server on a free
port and waits for a call with the· | 33 /// OAuth 2.0 verification code receiver that runs a local server on a free
port and waits for a call with the· |
34 /// authorization verification code. | 34 /// authorization verification code. |
35 /// </summary> | 35 /// </summary> |
36 public class LocalServerCodeReceiver : ICodeReceiver | 36 public class LocalServerCodeReceiver : ICodeReceiver |
37 { | 37 { |
38 private static readonly ILogger Logger = ApplicationContext.Logger.ForTy
pe<LocalServerCodeReceiver>(); | 38 private static readonly ILogger Logger = ApplicationContext.Logger.ForTy
pe<LocalServerCodeReceiver>(); |
39 | 39 |
40 /// <summary>The call back format. Expects one port parameter.</summary> | 40 /// <summary>The call back format. Expects one port parameter.</summary> |
41 private const string LoopbackCallback = "http://localhost:{0}/authorize/
"; | 41 private const string LoopbackCallback = "http://localhost:{0}/authorize/
"; |
42 | 42 |
43 /// <summary>Close HTML tag to return the brwoser so it will close itsel
f.</summary> | 43 /// <summary>Close HTML tag to return the browser so it will close itsel
f.</summary> |
44 private const string ClosePageResponse = | 44 private const string ClosePageResponse = |
45 @"<html> | 45 @"<html> |
46 <head><title>OAuth 2.0 Authentication Token Received</title></head> | 46 <head><title>OAuth 2.0 Authentication Token Received</title></head> |
47 <body> | 47 <body> |
48 Received verification code. Closing... | 48 Received verification code. Closing... |
49 <script type='text/javascript'> | 49 <script type='text/javascript'> |
50 window.setTimeout(function() { | 50 window.setTimeout(function() { |
51 window.open('', '_self', '');· | 51 window.open('', '_self', '');· |
52 window.close();· | 52 window.close();· |
53 }, 1000); | 53 }, 1000); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 listener.Start(); | 116 listener.Start(); |
117 return ((IPEndPoint)listener.LocalEndpoint).Port; | 117 return ((IPEndPoint)listener.LocalEndpoint).Port; |
118 } | 118 } |
119 finally | 119 finally |
120 { | 120 { |
121 listener.Stop(); | 121 listener.Stop(); |
122 } | 122 } |
123 } | 123 } |
124 } | 124 } |
125 } | 125 } |
LEFT | RIGHT |