crisi | 17 May 22:15 2011
Picon

Problems with GWT 2.3 and gwt-oauth2-0.1-alpha

Hi guys

I created a new GWT project, added the oauth library and wrote the code to get a token

        String AUTH_URL = "https://accounts.google.com/o/oauth2/auth";
        String CLIENT_ID = "asdasd"; // available from the APIs console
        String TASKS_WRITE_SCOPE = "https://www.googleapis.com/auth/tasks";

        AuthRequest req = new AuthRequest(AUTH_URL, CLIENT_ID)
            .withScopes(TASKS_WRITE_SCOPE);
       
        Auth.get().login(req, new Callback<String, Throwable>() {
              <at> Override
              public void onSuccess(String token) {
                // You now have the OAuth2 token needed to sign authenticated requests.
                  RootPanel.get().add(new Label("success"));
              }
              <at> Override
              public void onFailure(Throwable caught) {
                // The authentication process failed for some reason, see caught.getMessage()
                  RootPanel.get().add(new Label("fail"));
              }
            });

The first problem i encountered was, that the Callback.class was missing. Meaning there was no such class in import com.google.gwt.core.client
So i downloaded the class from http://code.google.com/p/google-web-toolkit/source/browse/trunk/user/src/com/google/gwt/core/client/Callback.java?spec=svn9872&r=9872 and made the appropriate package.
After this step the errors in eclipse disappeared.

The next problem now is, that when i run my project as web application the authorization seems to fail. I get a redirect_uri_mismatch.
Now I know that the uri in the google api console has to match but I don't know how to set the correct url.
If I run my project it runs under http://127.0.0.1:8888/GoogleTasks.html?gwt.codesvr=127.0.0.1:9997.

I tried to make it run with these uris so far:

  • http://127.0.0.1:8888 and http://127.0.0.1:8888/oauth2callback
  • http://localhost and http://localhost/oauth2callback
  • http://127.0.0.1 and http://127.0.0.1/oauth2callback
All these with no success so far.

Has anyone a tip for me? It's also strange that the Callback.class was not in the core library of gwt? Or is this all because the oauth library is still alpha? Should I better do it on my own? Meaning generating the auth uri by myself?

Thanks in advance, Chris.

redirect_uri_mismatch

Error 400

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
crisi | 17 May 22:55 2011
Picon

Re: Problems with GWT 2.3 and gwt-oauth2-0.1-alpha

ok it worked, i had to whitelist the following url

http://127.0.0.1:8888/googletasks/oauthWindow.html

oauthWindow.html is hardcoded in the authimpl.class

    // Default to use the bundled oauthWindow.html
        GWT.getModuleBaseURL() + "oauthWindow.html");

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Jason Hall | 18 May 17:47 2011
Picon

Re: Problems with GWT 2.3 and gwt-oauth2-0.1-alpha

Hey crisi,


First of all, thanks for trying out the library!

(Incidentally, sorry there wasn't a mailing list for the library itself for you to ask this question, I will create one now)

As you found, you will need to whitelist the callback URL for both your server's URL and your localhost for testing. I'll update the docs to make this clearer.

Also, for Callback, I thought this was in GWT 2.3... -- if that's not the case, I'll probably update the library to either not rely on it, or update the documentation to make it clear that you must use GWT trunk for the time being.

As the library is in alpha, there are some rough edges (as you've found), and I hope to make it much smoother in the near future. Thanks again for pointing these out :)

- Jason

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Gmane