2
votes

I used Windows Azure Mobile Services for Xamarin Android to authenticate the User for Google and obtained the Authentication Token as

while(_currentUser == null){
_currentUser = await _mobileClient.LoginAsync(context, 
 MobileServiceAuthenticationProvider.Google);
}

var authToken = _currentUser.MobileServiceAuthenticationToken;

var url = "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + authToken;
var request = WebRequest.Create (url)
var response = request.GetResponse ();

I get an an HTTP 401 Error : Unauthorized. I want to get the User Info using this auth token. Is the auth token being returned from the Azure Mobile Services not fit for this purpose? Any ideas will be appreciated.

Thanks.

1

1 Answers

2
votes

The token returned by LoginAsync is an Azure Mobile Service token, not a Google token. If you want to get the access token to be able to talk to the google API, you actually need to go to the server side and retrieve the information at that point, via the user object passed to the scripts.

The post at http://blogs.msdn.com/b/carlosfigueira/archive/2012/10/25/getting-user-information-on-azure-mobile-services.aspx has more information on how to get that access token.