Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.0.6
- Fixed parameter encoding

## 1.0.5
- Allow `oauth_callback_confirmed=1` in addition to `oauth_callback_confirmed=true`
- Add example
Expand Down
23 changes: 19 additions & 4 deletions lib/src/authorization_header.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
library authorization_header;

import 'client_credentials.dart';
import 'credentials.dart';
// import 'package:uuid/uuid.dart';

import 'signature_method.dart';
import 'client_credentials.dart';
import 'credentials.dart';

/// A class describing Authorization Header.
/// http://tools.ietf.org/html/rfc5849#section-3.5.1
Expand Down Expand Up @@ -60,6 +60,21 @@ class AuthorizationHeader {
return authHeader;
}

/// Percent-encodes the [param].
///
/// All characters except uppercase and lowercase letters, digits and the
/// characters `-_.~` are percent-encoded.
///
/// See https://oauth.net/core/1.0a/#encoding_parameters.
String _encodeParam(String param) {
return Uri.encodeComponent(param)
.replaceAll('!', '%21')
.replaceAll('*', '%2A')
.replaceAll("'", '%27')
.replaceAll('(', '%28')
.replaceAll(')', '%29');
}

/// Create signature in ways referred from
/// https://dev.twitter.com/docs/auth/creating-signature.
String _createSignature(
Expand All @@ -78,10 +93,10 @@ class AuthorizationHeader {
// that will be signed.
final Map<String, String> encodedParams = <String, String>{};
params.forEach((String k, String v) {
encodedParams[Uri.encodeComponent(k)] = Uri.encodeComponent(v);
encodedParams[_encodeParam(k)] = _encodeParam(v);
});
uri.queryParameters.forEach((String k, String v) {
encodedParams[Uri.encodeComponent(k)] = Uri.encodeComponent(v);
encodedParams[_encodeParam(k)] = _encodeParam(v);
});
params.remove('realm');

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: oauth1
version: 1.0.5
version: 1.0.6
description: "\"RFC 5849: The OAuth 1.0 Protocol\" client implementation for Dart."
homepage: https://github.com/nbspou/dart-oauth1
author: kumar8600 <kumar1@hotmail.co.jp>
Expand Down