title: How To Get Data From Fitbit Oauth Authentication
body: <p>I am implementing an <code>OAuth</code> authentication for <code>Fitbit</code>. And I have done all the process. Please refer the screen shots.</p>
  
  <p>for this I have code on my controller like</p>
  
  <pre><code>class MyController {
  
      def myService;
  
      static defaultAction = "getUserDetails"
      String subscriber_id = "1";
  
      def getUserDetails() {
          if (request.getParameter("completeAuthorization") != null) {
              forward(action: 'showUserInfo')
          }
          else {
              try {
  
                  response.sendRedirect(FitBitAPI.getBean().getResourceOwnerAuthorizationURL(new LocalUserDetail("-"), grailsApplication.config.myBaseUrl + "/my/showUserInfo?completeAuthorization="));
              }
              catch (FitbitAPIException e) {
                  throw new ServletException("Exception during performing authorization", e);
              }
  
          }
      }
  
      def showUserInfo() {
          /*println "${params}--------------------------------"*/
          render {params}
  
  
          APIResourceCredentials resourceCredentials = myService.getCredentials(params)
          UserInfo userInfo;
          println "=====================gggggg================================================&gt;&gt;&gt;&gt;"+resourceCredentials
          try {
              userInfo = FitBitAPI.getBean()?.getClient()?.getUserInfo(new LocalUserDetail(resourceCredentials.getLocalUserId()));
              println "===================after FitBitAPI==============================================="
              [userInfo: userInfo]
              println "===================user Info====================================================="
  
          } catch (FitbitAPIException e) {
              throw new ServletException("Exception during getting user info", e);
          }
          [params:params]
      }
  }
  </code></pre>
  
  <p>At first I create a link on my index page and on click <code>getUserDetails()</code> call like -----
  <img src="https://i.stack.imgur.com/0wdtD.png" alt="enter image description here"></p>
  
  <p>and when I click on this link Fitbit the OAuth page open like..
  <img src="https://i.stack.imgur.com/X5R7g.png" alt="enter image description here"></p>
  
  <p>and after passing all the credential i have found an error --
  <img src="https://i.stack.imgur.com/9y5Uz.png" alt="enter image description here"></p>