Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Authorization Code -- PATCH FILE #3

Open
Gerst20051 opened this issue Aug 15, 2014 · 1 comment
Open

Return Authorization Code -- PATCH FILE #3

Gerst20051 opened this issue Aug 15, 2014 · 1 comment

Comments

@Gerst20051
Copy link

Can you please advise me? @bumpmann @thyb @william26

This Is How You Do It With JavaScript.

OAuth.popup(provider, {
    state: oauthstate
}).done(handleOAuthAuthorization);
function handleOAuthAuthorization(result){
    $.ajax({
        url: 'index.php',
        type: 'POST',
        dataType: 'json',
        data: {
            code: result.code
        }
    }).done(function(r){
        handleOAuthCallback(r);
    });
}

What I'm Trying To Do With Android

OAuth o = new OAuth(this);
o.setOAuthdURL("https://andrew.easypparking.com:6284");
o.initialize("key");
JSONObject opts = new JSONObject();
JSONObject json = null;
try {
    json = getPostJSON("https://andrew.easypparking.com/apps/mobile/oauth/index.php?resource=genstate");
    opts.put("state", json.getString("oauthstate"));
} catch (JSONException e) {
    e.printStackTrace();
}
try {
    opts.put("oauthprovider", provider);
} catch (JSONException e) {
    e.printStackTrace();
}
o.popup(provider, opts, CurrentCallbackActivity.this);
@Gerst20051 Gerst20051 changed the title How To Got Authorization Code Back? How To Get Authorization Code Back? Aug 18, 2014
@Gerst20051 Gerst20051 changed the title How To Get Authorization Code Back? How To Get Authorization Code Back? PATCH Aug 18, 2014
@Gerst20051
Copy link
Author

From 9360ee7a97edbfd175919f94098475584aa6b0ae Mon Sep 17 00:00:00 2001
From: Andrew Gerst <[email protected]>
Date: Mon, 18 Aug 2014 19:16:51 -0400
Subject: [PATCH] fixed dialog to return authorization code
---
 src/io/oauth/OAuthData.java   | 3 ++-
 src/io/oauth/OAuthDialog.java | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/io/oauth/OAuthData.java b/src/io/oauth/OAuthData.java
index 7106682..878e080 100644
--- a/src/io/oauth/OAuthData.java
+++ b/src/io/oauth/OAuthData.java
@@ -16,9 +16,10 @@ public class OAuthData {
 
    public String provider;     /** name of the provider */
    public String state;        /** state send */
+   public String code;     /** authorization code */
    public String token;        /** token received */
    public String secret;       /** secret received (only in oauth1) */
-   public String status;       /** status of the request (succes, error, ....) */
+   public String status;       /** status of the request (success, error, ....) */
    public String expires_in;   /** if the token expires */
    public String error;        /** error encountered */
    public JSONObject request;  /** API request description */
diff --git a/src/io/oauth/OAuthDialog.java b/src/io/oauth/OAuthDialog.java
index 69ad7f4..ce25804 100644
--- a/src/io/oauth/OAuthDialog.java
+++ b/src/io/oauth/OAuthDialog.java
@@ -146,6 +146,8 @@ public class OAuthDialog extends Dialog {
                    mdata.provider = jsonObj.getString("provider");
                    mdata.state = jsonObj.getString("state");
                    JSONObject data = jsonObj.getJSONObject("data");
+                   if (data.has("code"))
+                       mdata.code = data.getString("code");
                    if (data.has("access_token"))
                        mdata.token = data.getString("access_token");
                    else if (data.has("oauth_token"))
-- 
2.0.0

@Gerst20051 Gerst20051 changed the title How To Get Authorization Code Back? PATCH Return Authorization Code -- PATCH FILE Aug 18, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant