Skip to content

ldclakmal/ballerina-oauth1.0a

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ballerina OAuth1.0a

Ballerina OAuth1.0a is an RFC 5849 standards-compliant library for Ballerina.

This module provides a method for clients to access server resources on behalf of a resource owner (such as a different client or an end-user) as specified in the RFC 5849. It also provides a process for end-users to authorize third-party access to their server resources without sharing their credentials (typically, a username and password pair), using user-agent redirections.

This module facilitates auth providers that are to be used by the clients and listeners of different protocol connectors.

Compatibility

Version
Ballerina Language Swan Lake GA

Examples

import ballerina/http;
import ballerina/io;
import ldclakmal/oauth1;

public function main() returns error? {
    oauth1:ClientOAuthHandler oauthHandler = new({
        signatureMethod: oauth1:HMAC_SHA1,
        consumerKey: "dpf43f3p2l4k3l03",
        consumerSecret: "kd94hf93k423kf44",
        accessToken: "hh5s93j4hdidpola",
        accessTokenSecret: "pfkkdhi9sl3r4s00",
        realm: "Photos",
        nonce: "7d8f3e4a"
    });
    map<string|string[]> securityHeaders = check oauthHandler.getSecurityHeaders("GET", 
        "https://photos.example.net/request?type=jpg&maxsize=10mb");
    final http:Client clientEP = check new("https://photos.example.net");
    json payload = check clientEP->get("/request?type=jpg&maxsize=10mb", securityHeaders);
    io:println(payload);
}