Java – how to use resteasy to implement OAuth 2.0 in Google App Engine?

I am developing Google App Engine rest service. I want to use OAuth 2.0 for authentication I add the following code to my service method to check for valid users, and it throws an exception when I am not authenticated

try 
{
    final OAuthService oauth = OAuthServiceFactory.getOAuthService();
    final User user = oauth.getCurrentUser();
}
catch (final OAuthRequestException e)
{
    throw new RuntimeException(e);
}

Now I want to authenticate this using a command - line program written in Java and python

I spent hours searching Google and stackoverflow, and I couldn't find a clear example of how to use non browser applications to authenticate my gae applications I found many examples of how to authenticate Google's own API, but no examples of authentication for my own Google App Engine Application

Can anyone provide instructions on how to authenticate Google App Engine applications using Java or Python?

Solution

solution

I finally ran OAuth 2.0 on my Google App Engine Application I have uploaded some sample command line tool client code to my GitHub account There is too much code to publish this code in the code box I will update this answer when I complete a full blog post on how to make it work and how the code works

sleep without any anxiety

Use the code published in my question to access the user authenticated as the first thing in each service method. If the user is not authenticated, it will throw an exception

integral

Thanks to f á bio uechi for releasing some main work codes, only some updates are needed I made a little update and refactored it from what he had done

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>