You may also want to look at:
https://github.com/mozilla-b2g/gaia/tree/master/dev_apps
specifically contacts-ds-provider1 and contacts-ds-provider2

--
Jason Weathersby


----- Original Message -----
From: "Jason Weathersby" <[email protected]>
To: "AJ ONeal" <[email protected]>
Cc: [email protected]
Sent: Tuesday, September 30, 2014 10:18:44 PM
Subject: Re: [b2g] WebActivities - launching an app from Firefox OS browser

I am not sure this is the best way but I found similar code somewhere but do 
not remember where :)
I got this to work with Facebook using:
        pickLogin.onclick = function () {
        var ruri = 
"https://www.facebook.com/dialog/oauth?client_id={myid}&redirect_uri=https://www.facebook.com/connect/login_success.html";;
                        window.open(ruri);      
                        
        };

Then using the redirect manifest field

  "redirects": [
    {"from": "https://www.facebook.com/connect/login_success.html";,
    "to": "/redirects/auth.html"}
  ]

Where auth.html under my redirects can query for the the token.  


--
Jason Weathersby


----- Original Message -----
From: "AJ ONeal" <[email protected]>
To: [email protected]
Sent: Tuesday, September 30, 2014 9:58:38 PM
Subject: Re: [b2g] WebActivities - launching an app from Firefox OS browser

I understand conceptually how to perform OAuth2 via an iFrame and I've done it 
before. What I can't figure out is how to redirect back to the app.

Can someone give a working example or a link to a *simple* github repo?

I imagine the flow to be something like this:

w = window.open("/oauth-open.html", "oauth-dialog");
window.finishOauth(access_token) {
  window.access_token = access_token;
  w.close();
}

In my oauth-open.html I would put a link such as

http://example.com/oauth/connect?redirect_uri={{what-do-i-put-here???/oauth-close.html}}

And then in my oauth-close.html in my app I would read the access_token from 
the query parameter and pass it back to my main app with 
window.opener.finishOauth(access_token)

But I'm missing what the redirect_uri should be and I'm not clear on what needs 
to be in the manifest.webapp to allow all of this to happen.

Please fill in some of the gaps for me. Thanks. :-D
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to