wuman / android-oauth-client

Android OAuth Client (android-oauth-client) is a library that helps to easily add an OAuth flow to an existing Android application.
Apache License 2.0
425 stars 107 forks source link

Does this library supports "Resource owner credentials grant"? #56

Closed danishsatkut closed 7 years ago

danishsatkut commented 8 years ago

I am a backend developer checking out some android oauth2 libraries. I want to know if this library supports the grant type "Resource owner credentials" as specified in OAuth specification. If not can anybody point me in the direction of the library that does?

Thanks.

KeitelDOG commented 8 years ago

Too bad if this package doesn't have this. I'm the owner of a website, and the app version doesn't need to be trusted again. So I want to make username password credentials like this one https://github.com/danielsz/android-oauth2-client

But this package is not maintained since may 2014

dmfs commented 8 years ago

I don't want to hijack this issue, but since @Agent47DarkSoul asked: we've published a library to support Resource Owner Credentials Grant and all other grants of RFC 6749 called oauth2-essentials.

KeitelDOG commented 8 years ago

Oh Great news. I'll give it a try next week. Cause I have hijacked rest client template from codepath to use concurrently both Authorization Code and (my add) Client Credentials grant type.

pradeepgudipati commented 7 years ago

No it does not support OAuth Resource Owner Also call OAuthPassword. However it is easy to build support for that create a new authorizeOAuthPassword method and put in the following code

public boolean authorizeOAuthPassword(String username, String password){
PasswordTokenRequest request = new PasswordTokenRequest(<NetHttpTransport Object>, JSON_FACTORY, new GenericUrl(<Token URL String>), username, password);
        request.set("client_id",this.client.getClientId());
        request.set("client_secret",this.client.getClientSecret());
        if (scopes != null && scopes.length > 0) {
            request.setScopes(Arrays.asList(scopes));
        }

        TokenResponse response = request.execute();
       <Credential Object> = new Credential(com.google.api.client.auth.oauth2.BearerToken.authorizationHeaderAccessMethod());
        <Credential Object>.setAccessToken(response.getAccessToken());
        <Credential Object>.setExpiresInSeconds(response.getExpiresInSeconds());
return true;
}
amanzan commented 5 years ago

@pradeepgudipati where would this method go? is it necessary to fork the repo?

pradeepgudipati commented 5 years ago

It's been 2 years since I used this and I don't exactly remember now !!!. Later, I ran into problems with WebView as google had blocked auth requests from Webview based calls. I moved to using Custom Tabs. I now use AppAuth Android Library