Sample code for 30+ languages & platforms
Dart

Generate OAuth 1.0 Signature

Demonstrates how to generate an OAuth 1.0 signature.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  // This example assumes the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  final oauth = CkOAuth1();

  // Set input parameters:
  oauth.oauthVersion = '1.0';
  oauth.oauthMethod = 'GET';
  oauth.oauthUrl = 'http://echo.lab.madgex.com/echo.ashx';
  oauth.consumerKey = 'key';
  oauth.consumerSecret = 'secret';
  oauth.token = 'accesskey';
  oauth.tokenSecret = 'accesssecret';
  oauth.nonce = '01020304050607080102030405060708';
  oauth.timestamp = '1441659763';
  // Can be "HMAC-SHA1", "HMAC-SHA256", "RSA-SHA1", or "RSA-SHA2"
  oauth.signatureMethod = 'HMAC-SHA256';

  try {
    oauth.generate();
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  // Examine the various outputs:

  print(oauth.queryString);
  print(oauth.baseString);
  print(oauth.hmacKey);
  print(oauth.signature);
  print(oauth.encodedSignature);
  print(oauth.authorizationHeader);
  print(oauth.generatedUrl);
}