fix loading loop in OAuth1

Signed-off-by: Luca Fulchir <luca@fulchir.it>
parent 31ecaa27
......@@ -19,14 +19,7 @@
* For details about the authors of this software, see the AUTHORS file. *
***************************************************************************/
include "OAuth1Data.iol"
interface OAuth1Interface {
RequestResponse:
RequestToken (OAuth1Info) (OAuth1Info) throws wrong_answer,
getReferral (OAuth1Info) (string),
getAccess (OAuth1Info) (OAuth1_parsed)
}
include "OAuth1Types.iol"
outputPort OAuth1 {
Interfaces: OAuth1Interface
......
......@@ -19,22 +19,22 @@
* For details about the authors of this software, see the AUTHORS file. *
***************************************************************************/
include "OAuth1.iol"
include "jolie/net/utils/HTTP.iol"
include "string_utils.iol"
include "console.iol"
include "OAuth1Types.iol"
include "OAuth1Data.iol"
inputPort OAuth1 {
Location: "local"
Interfaces: OAuth1Interface
}
execution { concurrent}
execution {sequential}
main {
[RequestToken (info) (token) {
scope (error_handler) {
install (wrong_answer =>
println@Console("OAuth1:wrong answer from server")();
......@@ -77,7 +77,7 @@ scope (error_handler) {
buildURI@HTTP (http_data) (output)
}] {nullProcess}
}]{nullProcess}
[getAccess (info) (output) {
if (!is_defined(info.token)) {
......@@ -95,6 +95,6 @@ scope (error_handler) {
parseAnswer@OAuth1Data (answer) (output)
}] {nullProcess}
}]{nullProcess}
}
......@@ -19,48 +19,8 @@
* For details about the authors of this software, see the AUTHORS file. *
***************************************************************************/
type OAuth1Pair:void {
.name :string
.value :string
}
type OAuth1Info:void {
.location_request :string
.location_authorize :string
.location_access :string
.method :string
.callback? :string
.realm? :string
.consumer_key :string
.secret? :string
.token? :string
.token_secret? :string
.verifier? :string
// HTTP additional user-specified parameters
.headers? :OAuth1Pair
.query? :OAuth1Pair
}
include "OAuth1Types.iol"
type OAuth1_pair:void {
.name :string
.value :string
}
type OAuth1_parsed:void {
.pair* :OAuth1_pair
}
type OAuth1_pairSearch:void {
.search :string
.pair* :OAuth1_pair
}
interface OAuth1DataInterface {
RequestResponse:
DataRequestToken (OAuth1Info) (string),
DataAccess (OAuth1Info) (string),
parseAnswer (string) (OAuth1_parsed) throws wrong_answer,
getPair (OAuth1_pairSearch) (string) throws not_found
}
outputPort OAuth1Data {
Interfaces: OAuth1DataInterface
}
......
......@@ -22,16 +22,16 @@
include "security_utils.iol"
include "time.iol"
include "string_utils.iol"
include "OAuth1Data.iol"
include "OAuth1Types.iol"
include "jolie/net/utils/Hmac.iol"
include "jolie/net/utils/HTTP.iol"
execution {sequential}
inputPort OAuth1Data{
Location: "local"
Interfaces: OAuth1DataInterface
}
execution {concurrent}
main {
[DataRequestToken (info) (postString)
......
/* *************************************************************************
* Copyright (C) 2013 by Luca Fulchir <luca@fulchir.it> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Library General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
* For details about the authors of this software, see the AUTHORS file. *
***************************************************************************/
type OAuth1Pair:void {
.name :string
.value :string
}
type OAuth1Info:void {
.location_request :string
.location_authorize :string
.location_access :string
.method :string
.callback? :string
.realm? :string
.consumer_key :string
.secret? :string
.token? :string
.token_secret? :string
.verifier? :string
// HTTP additional user-specified parameters
.headers? :OAuth1Pair
.query? :OAuth1Pair
}
type OAuth1_pair:void {
.name :string
.value :string
}
type OAuth1_parsed:void {
.pair* :OAuth1_pair
}
type OAuth1_pairSearch:void {
.search :string
.pair* :OAuth1_pair
}
interface OAuth1DataInterface {
RequestResponse:
DataRequestToken (OAuth1Info) (string),
DataAccess (OAuth1Info) (string),
parseAnswer (string) (OAuth1_parsed) throws wrong_answer,
getPair (OAuth1_pairSearch) (string) throws not_found
}
interface OAuth1Interface {
RequestResponse:
RequestToken (OAuth1Info) (OAuth1Info) throws wrong_answer,
getReferral (OAuth1Info) (string),
getAccess (OAuth1Info) (OAuth1_parsed)
}
......@@ -5,7 +5,6 @@ include "security_utils.iol"
include "time.iol"
include "string_utils.iol"
type accessAnswer:void {
.uid :int
.oauth_token :string
......@@ -16,13 +15,14 @@ interface OAuth1_HTTP {
access(accessAnswer)(string)
}
execution{ concurrent }
inputPort HTTP_Get {
Location: "socket://localhost:8011/"
Protocol: http
Protocol: http
Interfaces: OAuth1_HTTP
}
main
init
{
// data needed for the connection: where to connect, how and who we are
data.location_request = "https://api.dropbox.com/1/oauth/request_token";
......@@ -42,8 +42,10 @@ main
getReferral@OAuth1 (answer) (referr);
println@Console("\nauthenticate this app with:\n" + referr)();
println@Console("Now waiting for http refer")();
println@Console("Now waiting for http refer")()
}
main
{
[access (access) (response) {
if (is_defined(access.oauth_verifier)) {
data.verifier = access.oauth_verifier
......@@ -60,5 +62,6 @@ main
tokens.pair[i].value)()
}
}
}
......@@ -23,6 +23,7 @@ inputPort HTTP_Get {
main
{
ERR="Error";
// data needed for the connection: where to connect, how and who we are
data.location_authorize = "https://accounts.google.com/o/oauth2/auth";
data.location_access = "https://accounts.google.com/o/oauth2/token";
......@@ -40,8 +41,6 @@ main
// the authentication code needed.
println@Console ("Now waiting for authorization redirect...")();
ERR="Error";
[code(codeRequest) (out) {
out = "OK";
if (is_defined(codeRequest.error)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment