OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// A client library for authenticating with a remote service via OAuth2 on | 5 /// A client library for authenticating with a remote service via OAuth2 on |
6 /// behalf of a user, and making authorized HTTP requests with the user's OAuth2 | 6 /// behalf of a user, and making authorized HTTP requests with the user's OAuth2 |
7 /// credentials. | 7 /// credentials. |
8 /// | 8 /// |
9 /// ## Installing ## | 9 /// ## Installing ## |
10 /// | 10 /// |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 /// // `redirect` is an imaginary function that redirects the resource | 89 /// // `redirect` is an imaginary function that redirects the resource |
90 /// // owner's browser. | 90 /// // owner's browser. |
91 /// return redirect(grant.getAuthorizationUrl(redirectUrl)).then((_) { | 91 /// return redirect(grant.getAuthorizationUrl(redirectUrl)).then((_) { |
92 /// // Another imaginary function that listens for a request to | 92 /// // Another imaginary function that listens for a request to |
93 /// // `redirectUrl`. | 93 /// // `redirectUrl`. |
94 /// return listen(redirectUrl); | 94 /// return listen(redirectUrl); |
95 /// }).then((request) { | 95 /// }).then((request) { |
96 /// // Once the user is redirected to `redirectUrl`, pass the query | 96 /// // Once the user is redirected to `redirectUrl`, pass the query |
97 /// // parameters to the AuthorizationCodeGrant. It will validate them | 97 /// // parameters to the AuthorizationCodeGrant. It will validate them |
98 /// // and extract the authorization code to create a new Client. | 98 /// // and extract the authorization code to create a new Client. |
99 /// return grant.handleAuthorizationResponse(request.queryParameters); | 99 /// return grant.handleAuthorizationResponse(request.uri.queryParameters ); |
Søren Gjesse
2013/05/30 10:42:53
I decided to keep the long line here to make the s
| |
100 /// }) | 100 /// }) |
101 /// }).then((client) { | 101 /// }).then((client) { |
102 /// // Once you have a Client, you can use it just like any other HTTP | 102 /// // Once you have a Client, you can use it just like any other HTTP |
103 /// // client. | 103 /// // client. |
104 /// return client.read("http://example.com/protected-resources.txt") | 104 /// return client.read("http://example.com/protected-resources.txt") |
105 /// .then((result) { | 105 /// .then((result) { |
106 /// // Once we're done with the client, save the credentials file. This | 106 /// // Once we're done with the client, save the credentials file. This |
107 /// // ensures that if the credentials were automatically refreshed | 107 /// // ensures that if the credentials were automatically refreshed |
108 /// // while using the client, the new credentials are available for the | 108 /// // while using the client, the new credentials are available for the |
109 /// // next run of the program. | 109 /// // next run of the program. |
110 /// return credentialsFile.open(FileMode.WRITE).then((file) { | 110 /// return credentialsFile.open(FileMode.WRITE).then((file) { |
111 /// return file.writeString(client.credentials.toJson()); | 111 /// return file.writeString(client.credentials.toJson()); |
112 /// }).then((file) => file.close()).then((_) => result); | 112 /// }).then((file) => file.close()).then((_) => result); |
113 /// }); | 113 /// }); |
114 /// }).then(print); | 114 /// }).then(print); |
115 /// | 115 /// |
116 /// [pub]: http://pub.dartlang.org | 116 /// [pub]: http://pub.dartlang.org |
117 /// [pkg]: http://pub.dartlang.org/packages/oauth2 | 117 /// [pkg]: http://pub.dartlang.org/packages/oauth2 |
118 library oauth2; | 118 library oauth2; |
119 | 119 |
120 export 'src/authorization_code_grant.dart'; | 120 export 'src/authorization_code_grant.dart'; |
121 export 'src/client.dart'; | 121 export 'src/client.dart'; |
122 export 'src/credentials.dart'; | 122 export 'src/credentials.dart'; |
123 export 'src/authorization_exception.dart'; | 123 export 'src/authorization_exception.dart'; |
124 export 'src/expiration_exception.dart'; | 124 export 'src/expiration_exception.dart'; |
OLD | NEW |