diff --git a/lib/modules/Web.pmod/Api.pmod/Api.pike b/lib/modules/Web.pmod/Api.pmod/Api.pike index 8c4d47b5ffb1e92ddd1ffd160e492b15f5729a1a..a5a552c9a11dc2e0b8df716a142900e3a762ddbe 100755 --- a/lib/modules/Web.pmod/Api.pmod/Api.pike +++ b/lib/modules/Web.pmod/Api.pmod/Api.pike @@ -1,12 +1,11 @@ - //! Base class for implementing a @tt{(RESTful) WebApi@} like Facebook's //! Graph API, Instagram's API, Twitter's API and so on. //! //! @b{Note:@} This class is useless in it self, and is intended to be -//! inherited by classes implementing a given @tt{WebApi@}. +//! inherited by classes implementing a given @tt{Web.Api@}. //! -//! Look at the code in @[WebApi.Github], @[WebApi.Instagram], -//! @[WebApi.Linkedin] etc to see some examples of implementations. +//! Look at the code in @[Web.Api.Github], @[Web.Api.Instagram], +//! @[Web.Api.Linkedin] etc to see some examples of implementations. #if defined(SOCIAL_REQUEST_DEBUG) || defined(SOCIAL_REQUEST_DATA_DEBUG) # define TRACE(X...) werror("%s:%d: %s",basename(__FILE__),__LINE__,sprintf(X)) @@ -34,16 +33,16 @@ public int(0..1) utf8_decode = DECODE_UTF8; typedef function(mapping,Protocols.HTTP.Query:void) Callback; //! Typef for a parameter argument -typedef mapping|Auth.Params ParamsArg; +typedef mapping|Web.Auth.Params ParamsArg; //! Authorization object. //! //! @seealso -//! @[Auth.OAuth2] -protected Auth.OAuth2.Client _auth; +//! @[Web.Auth.OAuth2] +protected Web.Auth.OAuth2.Client _auth; //! Authentication class to use -protected constant AuthClass = Auth.OAuth2.Client; +protected constant AuthClass = Web.Auth.OAuth2.Client; protected mapping(string:string) default_headers = ([ "user-agent" : .USER_AGENT @@ -72,11 +71,11 @@ protected void create(string client_id, string client_secret, } //! Getter for the authentication object. Most likely this will be a class -//! derived from @[Auth.OAuth2.Client]. +//! derived from @[Web.Auth.OAuth2.Client]. //! //! @seealso -//! @[Auth.OAuth2.Client] or @[Auth.OAuth.Client] -Auth.OAuth2.Client `auth() +//! @[Web.Auth.OAuth2.Client] or @[Web.Auth.OWeb.Auth.Client] +Web.Auth.OAuth2.Client `auth() { return _auth; } @@ -85,12 +84,12 @@ Auth.OAuth2.Client `auth() //! Many API returns stuff like: //! //! @code -//! { -//! ... -//! "pagination" : { -//! "next" : "/api/v1/method/path?some=variables&page=2&per_page=20" -//! } -//! } +//! { +//! ... +//! "pagination" : { +//! "next" : "/api/v1/method/path?some=variables&page=2&per_page=20" +//! } +//! } //! @endcode //! //! If @tt{pagination->next@} is passed to this method it will return a path @@ -228,14 +227,14 @@ mixed call(string api_method, void|ParamsArg params, void|string http_method, void|string data, void|Callback cb) { http_method = upper_case(http_method || "get"); - Auth.Params p = Auth.Params(); + Web.Auth.Params p = Web.Auth.Params(); p->add_mapping(default_params()); if (params) p += params; if (_auth && !_auth->is_expired()) { if (string a = _auth->access_token) { - p += Auth.Param(ACCESS_TOKEN_PARAM_NAME, a); + p += Web.Auth.Param(ACCESS_TOKEN_PARAM_NAME, a); } } @@ -394,7 +393,7 @@ class Method //! Hidden constructor. This class can not be instantiated directly protected void create() { - if (this_program == WebApi.Api.Method) + if (this_program == Web.Api.Api.Method) error("This class can not be instantiated directly! "); } diff --git a/lib/modules/Web.pmod/Api.pmod/Facebook.pmod b/lib/modules/Web.pmod/Api.pmod/Facebook.pmod index 23b5b8fdd2bb435e2d8c44affd404328c2ba787e..897ce84c8f7c4afdede1843a9d19917371950133 100755 --- a/lib/modules/Web.pmod/Api.pmod/Facebook.pmod +++ b/lib/modules/Web.pmod/Api.pmod/Facebook.pmod @@ -1,13 +1,5 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! Instantiates the default Facebook API. -//! See @[WebApi.Api()] for further information about the arguments +//! See @[Web.Api.Api()] for further information. //! //! @param client_id //! Your application key/id @@ -26,9 +18,9 @@ this_program `()(string client_id, string client_secret, class Graph { - inherit WebApi.Api : parent; + inherit Web.Api.Api : parent; - protected constant AuthClass = Auth.Facebook; + protected constant AuthClass = Web.Auth.Facebook; //! The base uri to the Graph API constant API_URI = "https://graph.facebook.com"; @@ -109,7 +101,7 @@ class Graph // Just a convenience class protected class Method { - inherit WebApi.Api.Method; + inherit Web.Api.Api.Method; //! Internal convenience method public mixed get(string s, void|ParamsArg p, void|Callback cb) diff --git a/lib/modules/Web.pmod/Api.pmod/Github.pmod b/lib/modules/Web.pmod/Api.pmod/Github.pmod index 8924fc4e812220eb6ac0cacabb34745a71179700..dc9c455216eecd9339ef182309890554423c6448 100755 --- a/lib/modules/Web.pmod/Api.pmod/Github.pmod +++ b/lib/modules/Web.pmod/Api.pmod/Github.pmod @@ -1,13 +1,5 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! Instantiates the default Github API. -//! See @[WebApi.Api()] for further information about the arguments +//! See @[Web.Api.Api()] for further information. //! //! @param client_id //! Your application key/id @@ -26,9 +18,9 @@ this_program `()(string client_id, string client_secret, class Github { - inherit WebApi.Api : parent; + inherit Web.Api.Api : parent; - protected constant AuthClass = Auth.Github; + protected constant AuthClass = Web.Auth.Github; //! The base uri to the Github API constant API_URI = "https://api.github.com"; @@ -104,7 +96,7 @@ class Github // Just a convenience class protected class Method { - inherit WebApi.Api.Method; + inherit Web.Api.Api.Method; //! Internal convenience method public mixed get(string s, void|ParamsArg p, void|Callback cb) diff --git a/lib/modules/Web.pmod/Api.pmod/Google.pmod/Analytics.pmod b/lib/modules/Web.pmod/Api.pmod/Google.pmod/Analytics.pmod index f9088d2088125ffcf0ffff2713308700221ca74d..02d3180db6d55abc3fa64146a8a205a518414dea 100755 --- a/lib/modules/Web.pmod/Api.pmod/Google.pmod/Analytics.pmod +++ b/lib/modules/Web.pmod/Api.pmod/Google.pmod/Analytics.pmod @@ -1,13 +1,5 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! Instantiates the default Analytics API. -//! See @[WebApi.Api()] for further information about the arguments +//! See @[Web.Api.Api()] for further information. //! //! @param client_id //! Your application key/id @@ -26,9 +18,9 @@ this_program `()(string client_id, string client_secret, class V3 { - inherit WebApi.Google.Api : parent; + inherit Web.Api.Google.Api : parent; - protected constant AuthClass = Auth.Google.Analytics; + protected constant AuthClass = Web.Auth.Google.Analytics; //! API base URI. protected constant API_URI = "https://www.googleapis.com/analytics/v3"; diff --git a/lib/modules/Web.pmod/Api.pmod/Google.pmod/Plus.pmod b/lib/modules/Web.pmod/Api.pmod/Google.pmod/Plus.pmod index af17c2badf628643ff7bd3925f36c49029cb24bf..00f0e14fc8503f975dc344327e6f9392becbc3be 100755 --- a/lib/modules/Web.pmod/Api.pmod/Google.pmod/Plus.pmod +++ b/lib/modules/Web.pmod/Api.pmod/Google.pmod/Plus.pmod @@ -1,13 +1,5 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! Instantiates the default Google+ API. -//! See @[WebApi.Api()] for further information about the arguments +//! See @[Web.Api.Api()] for further information. //! //! @param client_id //! Your application key/id @@ -26,12 +18,12 @@ this_program `()(string client_id, string client_secret, class V1 { - inherit WebApi.Google.Api; + inherit Web.Api.Google.Api; //! API base URI. protected constant API_URI = "https://www.googleapis.com/plus/v1"; - protected constant AuthClass = Auth.Google.Plus; + protected constant AuthClass = Web.Auth.Google.Plus; //! Getter for the @[People] object which has methods for all @expr{people@} diff --git a/lib/modules/Web.pmod/Api.pmod/Google.pmod/module.pmod b/lib/modules/Web.pmod/Api.pmod/Google.pmod/module.pmod index 55f8c39383fe774609b518e45b4ba745de808f10..c343d1c3905b48e100d00b0c9039e1c7c6d84155 100755 --- a/lib/modules/Web.pmod/Api.pmod/Google.pmod/module.pmod +++ b/lib/modules/Web.pmod/Api.pmod/Google.pmod/module.pmod @@ -1,20 +1,12 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! Internal class ment to be inherited by other Google API's class Api { - inherit WebApi.Api : parent; + inherit Web.Api.Api : parent; // Just a convenience class protected class Method { - inherit WebApi.Api.Method; + inherit Web.Api.Api.Method; //! Internal convenience method protected mixed _get(string s, void|ParamsArg p, void|Callback cb) diff --git a/lib/modules/Web.pmod/Api.pmod/Instagram.pmod b/lib/modules/Web.pmod/Api.pmod/Instagram.pmod index ce2ecd1dd81756a010f9d41ce9d4b2a8b5efa73f..2d7ea3593e9e8252967c9f7c3c5b85689f0ff02c 100755 --- a/lib/modules/Web.pmod/Api.pmod/Instagram.pmod +++ b/lib/modules/Web.pmod/Api.pmod/Instagram.pmod @@ -1,7 +1,7 @@ //! Instagram API implementation. //! Instantiates the default Instagram API. -//! See @[WebApi.Api()] for further information about the arguments +//! See @[Web.Api.Api()] for further information. //! //! @param client_id //! Your application key/id @@ -21,9 +21,9 @@ this_program `()(string client_id, string client_secret, //! Class for communicating with version 1 of the Instagram API. class V1 { - inherit WebApi.Api : parent; + inherit Web.Api.Api : parent; - protected constant AuthClass = Auth.Instagram; + protected constant AuthClass = Web.Auth.Instagram; //! Getter for the @[Users] object which has methods for all @expr{users@} //! related Instagram API methods. @@ -168,7 +168,7 @@ class V1 //! Internal convenience class. protected class Method { - inherit WebApi.Api.Method; + inherit Web.Api.Api.Method; //! Internal convenience method protected mixed _get(string s, void|ParamsArg p, void|Callback cb) diff --git a/lib/modules/Web.pmod/Api.pmod/Linkedin.pmod b/lib/modules/Web.pmod/Api.pmod/Linkedin.pmod index 74a3b20637d9f497017696138f46b991f83c7838..a5e360c5b91c88e40028d658a8de2192c94df002 100755 --- a/lib/modules/Web.pmod/Api.pmod/Linkedin.pmod +++ b/lib/modules/Web.pmod/Api.pmod/Linkedin.pmod @@ -1,13 +1,5 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! Instantiates the default Github API. -//! See @[WebApi.Api()] for further information about the arguments +//! See @[Web.Api.Api()] for further information about the arguments //! //! @param client_id //! Your application key/id @@ -26,9 +18,9 @@ this_program `()(string client_id, string client_secret, class V1 { - inherit WebApi.Api : parent; + inherit Web.Api.Api : parent; - protected constant AuthClass = Auth.Linkedin; + protected constant AuthClass = Web.Auth.Linkedin; //! The base uri to the API constant API_URI = "https://api.linkedin.com/v1"; @@ -114,7 +106,7 @@ class V1 // Just a convenience class protected class Method { - inherit WebApi.Api.Method; + inherit Web.Api.Api.Method; //! Internal convenience method public mixed get(string s, void|ParamsArg p, void|Callback cb) diff --git a/lib/modules/Web.pmod/Api.pmod/Twitter.pmod b/lib/modules/Web.pmod/Api.pmod/Twitter.pmod index 4f3f29ee4bc6cd2e4f38144e8682d7bd78425e4d..29c9210f6f0291adb606513d18a37c7e485d2dd4 100755 --- a/lib/modules/Web.pmod/Api.pmod/Twitter.pmod +++ b/lib/modules/Web.pmod/Api.pmod/Twitter.pmod @@ -1,13 +1,5 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! Instantiates the default Twitter API. -//! See @[WebApi.Api()] for further information about the arguments +//! See @[Web.Api.Api()] for further information. //! //! @param client_id //! Your application key/id @@ -26,11 +18,11 @@ this_program `()(string client_id, string client_secret, class V1_1 { - inherit WebApi.Api : parent; + inherit Web.Api.Api : parent; constant API_URI = "https://api.twitter.com/1.1/"; - protected constant AuthClass = Auth.Twitter; + protected constant AuthClass = Web.Auth.Twitter; //! Getter for the @[Any] object which is a generic object for making request //! to the Twitter API @@ -109,7 +101,7 @@ class V1_1 // Just a convenience class protected class Method { - inherit WebApi.Api.Method; + inherit Web.Api.Api.Method; //! Internal convenience method public mixed get(string s, void|ParamsArg p, void|Callback cb) diff --git a/lib/modules/Web.pmod/Api.pmod/module.pmod b/lib/modules/Web.pmod/Api.pmod/module.pmod index e062ff2ff1a202952005135bb06dc4e5f1ac0bb2..0a4df604b208e73e663c2b8af0731f3619e5668c 100755 --- a/lib/modules/Web.pmod/Api.pmod/module.pmod +++ b/lib/modules/Web.pmod/Api.pmod/module.pmod @@ -1,6 +1,6 @@ -//! The @tt{WebApi@} has modules and classes for communicating with various -//! @tt{(RESTful)@} web api's such as @[WebApi.Facebook], -//! @[WebApi.Instagram], @[WebApi.Twitter] etc. +//! The @tt{Web.Api@} has modules and classes for communicating with various +//! @tt{(RESTful)@} web api's such as @[Web.Api.Facebook], +//! @[Web.Api.Instagram], @[Web.Api.Twitter] etc. //! Default user agent in HTTP calls constant USER_AGENT = "Mozilla 4.0 (Pike/" + __REAL_MAJOR__ + "." + diff --git a/lib/modules/Web.pmod/Auth.pmod/Facebook.pike b/lib/modules/Web.pmod/Auth.pmod/Facebook.pike index f10e7eadbf3f3833f6489b7095712858817ca38c..2cd52d2bce38c4c2152677cd5429a878ce7e40ae 100755 --- a/lib/modules/Web.pmod/Auth.pmod/Facebook.pike +++ b/lib/modules/Web.pmod/Auth.pmod/Facebook.pike @@ -1,14 +1,6 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! This class is used to OAuth2 authenticate agains Facebook -inherit Auth.OAuth2.Client; +inherit .OAuth2.Client; constant OAUTH_AUTH_URI = "https://graph.facebook.com/oauth/authorize"; constant OAUTH_TOKEN_URI = "https://graph.facebook.com/oauth/access_token"; diff --git a/lib/modules/Web.pmod/Auth.pmod/Github.pike b/lib/modules/Web.pmod/Auth.pmod/Github.pike index fd1bdea9fc75a91cfcbd0101c8c31cb6926d5744..98c7d5a0f4db31395a661c58d069edfa28934158 100755 --- a/lib/modules/Web.pmod/Auth.pmod/Github.pike +++ b/lib/modules/Web.pmod/Auth.pmod/Github.pike @@ -1,14 +1,6 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! This class is used to OAuth2 authenticate against Github -inherit Auth.OAuth2.Client; +inherit .OAuth2.Client; constant OAUTH_AUTH_URI = "https://github.com/login/oauth/authorize"; constant OAUTH_TOKEN_URI = "https://github.com/login/oauth/access_token"; diff --git a/lib/modules/Web.pmod/Auth.pmod/Google.pmod/module.pmod b/lib/modules/Web.pmod/Auth.pmod/Google.pmod/module.pmod index cfb50d6bfde4549e0fc9a9d63c771a8164449ce9..e1cb422da28b2ba4753277bc22d84f4c63d30363 100755 --- a/lib/modules/Web.pmod/Auth.pmod/Google.pmod/module.pmod +++ b/lib/modules/Web.pmod/Auth.pmod/Google.pmod/module.pmod @@ -4,7 +4,7 @@ //! For more info see @url{https://developers.google.com/+/web/api/rest/oauth@} class Authorization { - inherit Auth.OAuth2.Client; + inherit Web.Auth.OAuth2.Client; //! constant OAUTH_AUTH_URI = "https://accounts.google.com/o/oauth2/auth"; diff --git a/lib/modules/Web.pmod/Auth.pmod/Instagram.pike b/lib/modules/Web.pmod/Auth.pmod/Instagram.pike index 2ea5ae5b648f5b6dcffc4c49d5defb740b122929..2f38f4f4353d074b7ea10768cdc98a23be78ab3a 100755 --- a/lib/modules/Web.pmod/Auth.pmod/Instagram.pike +++ b/lib/modules/Web.pmod/Auth.pmod/Instagram.pike @@ -1,14 +1,6 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! This class is used to OAuth2 authenticate agains Instagram -inherit Auth.OAuth2.Client; +inherit .OAuth2.Client; //! Instagram authorization URI constant OAUTH_AUTH_URI = "https://api.instagram.com/oauth/authorize"; diff --git a/lib/modules/Web.pmod/Auth.pmod/Linkedin.pike b/lib/modules/Web.pmod/Auth.pmod/Linkedin.pike index 787c1e393dd9ce46e7c45773aa6fed700966bad3..a1ab950901873038c38127e92f04419320221b3b 100755 --- a/lib/modules/Web.pmod/Auth.pmod/Linkedin.pike +++ b/lib/modules/Web.pmod/Auth.pmod/Linkedin.pike @@ -1,14 +1,6 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! This class is used to OAuth2 authenticate against LinkedIn -inherit Auth.OAuth2.Client; +inherit .OAuth2.Client; //! @ignore constant ACCESS_TOKEN_PARAM_NAME = "oauth2_access_token"; diff --git a/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/Authentication.pike b/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/Authentication.pike index d99d7daf37ed9e32bc773996f3a23b7a880c165f..79148a73cb580bbe7a521f74f1aa05feccbdf7eb 100755 --- a/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/Authentication.pike +++ b/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/Authentication.pike @@ -1,17 +1,9 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! The purpose of this class is to streamline OAuth1 with OAuth2. //! This class will not do much on it's own, since its purpose is to //! be inherited by some other class implementing a specific authorization //! service. -inherit Auth.OAuth2.Client : oauth2; +inherit Web.Auth.OAuth2.Client : oauth2; inherit .Client : oauth; #include "oauth.h" @@ -214,7 +206,7 @@ string call(string|Standards.URI url, void|mapping|.Params args, Protocols.HTTP.Query q = r->submit(); - TRACE("Auth.OAuth.Authentication()->call(%O) : %O : %s\n", + TRACE("Web.Auth.OWeb.Auth.Authentication()->call(%O) : %O : %s\n", q, q->headers, q->data()); if (q->status != 200) { diff --git a/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/Client.pike b/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/Client.pike index 3fc1b6b06b277638f2c3d4f954788085cf177692..9285c6a49a90a0d92b4aba068066e55025054c8a 100755 --- a/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/Client.pike +++ b/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/Client.pike @@ -1,11 +1,3 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! OAuth client class //! //! @note diff --git a/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/Signature.pmod b/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/Signature.pmod index 1a094c603b1d4077e3b315235ed0b7a19f357ee2..6d8341f2ea1a2bebd69114c2105e0df678e540ec 100755 --- a/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/Signature.pmod +++ b/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/Signature.pmod @@ -1,11 +1,3 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - //! Module for creating OAuth signatures #include "oauth.h" diff --git a/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/oauth.h b/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/oauth.h index 8fa48b1e779f874946137615125f211a55962b15..46f389f1c3851f836d6b6a3973d9b56609d30677 100755 --- a/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/oauth.h +++ b/lib/modules/Web.pmod/Auth.pmod/OAuth.pmod/oauth.h @@ -1,11 +1,3 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> - - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - #ifndef _OAUTH_H #define _OAUTH_H diff --git a/lib/modules/Web.pmod/Auth.pmod/OAuth2.pmod b/lib/modules/Web.pmod/Auth.pmod/OAuth2.pmod index d1123a9ce622f09f0fb80045a41d928431359fa5..2aa709f8c1e9f4f49d2d19fef1eeb3c75dea5807 100755 --- a/lib/modules/Web.pmod/Auth.pmod/OAuth2.pmod +++ b/lib/modules/Web.pmod/Auth.pmod/OAuth2.pmod @@ -1,7 +1,7 @@ //! OAuth2 client //! //! A base OAuth2 class can be instantiated either via @[`()] -//! (@tt{Auth.OAuth2(params...)@}) or via @[Auth.OAuth2.Base()]. +//! (@tt{Web.Auth.OAuth2(params...)@}) or via @[Web.Auth.OAuth2.Base()]. #ifdef SOCIAL_REQUEST_DEBUG # define TRACE(X...) werror("%s:%d: %s", basename(__FILE__),__LINE__,sprintf(X)) @@ -383,27 +383,29 @@ class Base //! Additional argument. string get_auth_uri(string auth_uri, void|mapping args) { - Auth.Params p = Auth.Params(Auth.Param("client_id", _client_id), - Auth.Param("response_type", _response_type)); + Web.Auth.Params p; + p = Web.Auth.Params(Web.Auth.Param("client_id", _client_id), + Web.Auth.Param("response_type", _response_type)); if (args && args->redirect_uri || _redirect_uri) - p += Auth.Param("redirect_uri", + p += Web.Auth.Param("redirect_uri", args && args->redirect_uri || _redirect_uri); if (STATE) - p += Auth.Param("state", (string) Standards.UUID.make_version4()); + p += Web.Auth.Param("state", (string) Standards.UUID.make_version4()); if (args && args->scope || _scope) { string sc = get_valid_scopes(args && args->scope || _scope); if (sc && sizeof(sc)) { _scope = sc; - p += Auth.Param("scope", sc); + p += Web.Auth.Param("scope", sc); } } if (args && args->access_type || _access_type) { - p += Auth.Param("access_type", args && args->access_type || _access_type); + p += Web.Auth.Param("access_type", args && + args->access_type || _access_type); if (!_access_type && args && args->access_type) _access_type = args->access_type; @@ -441,7 +443,7 @@ class Base //! //! @returns //! If @expr{OK@} a Pike encoded mapping (i.e it's a string) is returned - //! which can be used to populate an @[Auth.OAuth2] object at a later time. + //! which can be used to populate an @[Web.Auth.OAuth2] object at a later time. //! //! The mapping looks like //! @mapping @@ -459,8 +461,8 @@ class Base { TRACE("request_access_token: %O, %O\n", oauth_token_uri, code); - Auth.Params p = get_default_params(); - p += Auth.Param("code", code); + Web.Auth.Params p = get_default_params(); + p += Web.Auth.Param("code", code); if (async_cb) { do_query(oauth_token_uri, p, async_cb); @@ -493,8 +495,8 @@ class Base if (!gettable->refresh_token) error("No refresh_token in object! "); - Auth.Params p = get_default_params(GRANT_TYPE_REFRESH_TOKEN); - p += Auth.Param("refresh_token", gettable->refresh_token); + Web.Auth.Params p = get_default_params(GRANT_TYPE_REFRESH_TOKEN); + p += Web.Auth.Param("refresh_token", gettable->refresh_token); if (async_cb) { do_query(oauth_token_uri, p, async_cb); @@ -521,7 +523,7 @@ class Base //! successfull or not. The second argument will be a string. If the request //! failed it will be an error message. If it succeeded it will be the result //! as a string encoded with @[predef::encode_value()]. - protected string do_query(string oauth_token_uri, Auth.Params p, + protected string do_query(string oauth_token_uri, Web.Auth.Params p, void|function(bool,string:void) async_cb) { int qpos = 0; @@ -570,6 +572,10 @@ class Base Protocols.HTTP.Session.Request q; q = sess->post_url(oauth_token_uri, p->to_mapping()); + if (!q) { + error("Unable to create request!\n"); + } + TRACE("Query OK: %O : %O : %s\n", q, q->status(), q->data()); string c = q && q->data(); @@ -594,23 +600,23 @@ class Base //! Returns a set of default parameters //! //! @param grant_type - protected Auth.Params get_default_params(void|string grant_type) + protected Web.Auth.Params get_default_params(void|string grant_type) { - Auth.Params p; - p = Auth.Params(Auth.Param("client_id", _client_id), - Auth.Param("redirect_uri", _redirect_uri), - Auth.Param("client_secret", _client_secret), - Auth.Param("grant_type", grant_type || _grant_type)); + Web.Auth.Params p; + p = Web.Auth.Params(Web.Auth.Param("client_id", _client_id), + Web.Auth.Param("redirect_uri", _redirect_uri), + Web.Auth.Param("client_secret", _client_secret), + Web.Auth.Param("grant_type", grant_type || _grant_type)); if (STATE) { - p += Auth.Param("state", (string)Standards.UUID.make_version4()); + p += Web.Auth.Param("state", (string)Standards.UUID.make_version4()); } return p; } //! Checks if the authorization is renewable. This is true if the - //! @[Auth.OAuth2.Base()] object has been populated from - //! @[Auth.OAuth2.Base()->set_from_cookie()], i.e the user has been + //! @[Web.Auth.OAuth2.Base()] object has been populated from + //! @[Web.Auth.OAuth2.Base()->set_from_cookie()], i.e the user has been //! authorized but the session has expired. int(0..1) is_renewable() { @@ -727,8 +733,8 @@ class Base ]); protected constant json_decode = Standards.JSON.decode; - protected constant Params = Auth.Params; - protected constant Param = Auth.Param; + protected constant Params = Web.Auth.Params; + protected constant Param = Web.Auth.Param; protected mapping gettable = ([ "access_token" : 0, "refresh_token" : 0, diff --git a/lib/modules/Web.pmod/Auth.pmod/Twitter.pike b/lib/modules/Web.pmod/Auth.pmod/Twitter.pike index c2ce6a2bad01fad4209ae651d28e6facb9895882..3772cd224b34283fdf06e5ec30071fb4ee082a0a 100755 --- a/lib/modules/Web.pmod/Auth.pmod/Twitter.pike +++ b/lib/modules/Web.pmod/Auth.pmod/Twitter.pike @@ -1,12 +1,6 @@ -/* - Author: Pontus Östlund <https://profiles.google.com/poppanator> +//! Twitter authentication class - Permission to copy, modify, and distribute this source for any legal - purpose granted as long as my name is still attached to it. More - specifically, the GPL, LGPL and MPL licenses apply to this software. -*/ - -inherit Auth.OAuth.Authentication; +inherit Web.Auth.OAuth.Authentication; //! The endpoint to send request for a request token constant REQUEST_TOKEN_URL = "https://api.twitter.com/oauth/request_token";