Github with coderwall Application in Rhomobile


1 min read

I recently tried to integrate github and coderwall in rhomobile application. Using github oauth we can authenticate user and show the following details of user and coderwall patches of user

1.User Repositories
2.User Forked Repositories
3.User Watched Repositories
4.User Following
5.User Follower

Now lets see how to authenticate user in github
First we need to register our application in github:developer site.we will use client_id and client_secret of registered application as shown

    [source language=”ruby”]
    def github_login
    local_callback_url =url_for( :action => :github_callback )
    call_back_url = RedirectServiceURL + “/” + ‘’ +
    System.get_property(‘rhodes_port’).to_s + local_call_back_url
    url =”

From above method we can get @params[“code”] to access token of current user. We have used following callback url to redirect our rhombile application since rhomobile have random port number

    [source language=”ruby”]
    RedirectServiceURL = “” //used to redirect application url//

You can attain port number as

    [source language=”ruby”]

Lets see how to process @params[code] to get user token as shown

    [source language=”ruby”]
    def github_callback
    :url => “” + code
    user_info = “” + @@token[“body”]
    :url => user_info,
    WebView.navigate( url_for :action => :listing )

So far we saw how to authenticate user and get token. We can also get access to public, forked and watched repositories using Username as shown below

    [source language=”ruby”]
    my_repo_url = “”
    + Rho::RhoConfig.username #=> Get Public and forked repositories info
    my_watched_url = “”
    + Rho::RhoConfig.username #=> Get watched repositories

Using callback events for the each url, we can manipulate data and display it
We can also list of followers and following users using the below url

    [source language=”ruby”]
    my_following_url = “”
    + Rho::RhoConfig.username + “/following” #=> Following url
    my_followers_url = “”
    + Rho::RhoConfig.username + “/followers” # => Followers list

Finally we will integrate Coderwall_page in github rhomobile application. Since Coderwall use github authentication to give patches, we can easily integrate coderwall page in github rhomobile application. We get details of user in coder wall in JSON format as shown

    [source language=”ruby”]
    user_details_url = “{Rho::RhoConfig.username}.json”
    result = Rho::AsyncHttp.get(:url => auth_url)

The execution of GET request will give User details.

Some of the screenshots taken from Android Mobile

I hope this blog will be helpful for integrating github authentication in rhomobile. Source code of application is available at feel free to improve and send me a pull request. Any suggestion or comments are welcome.

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *