Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

oauth API with the Access Token to retrieve some of users information.

private async void getgoogleplususerdataSer(string access_token)
{
    try
    {
        HttpClient client = new HttpClient();
        var urlProfile = "https://www.googleapis.com/oauth2/v1/userinfo?access_token=" + access_token;

        client.CancelPendingRequests();
        HttpResponseMessage output = await client.GetAsync(urlProfile);

        if (output.IsSuccessStatusCode)
        {
            string outputData = await output.Content.ReadAsStringAsync();
            GoogleUserOutputData serStatus = JsonConvert.DeserializeObject<GoogleUserOutputData>(outputData);

            if (serStatus != null)
            {
                 // You will get the user information here.
            }
        }
    }
    catch (Exception ex)
    { 
         //catching the exception
    }
}

public class GoogleUserOutputData
{
    public string id { get; set; }
    public string name { get; set; }
    public string given_name { get; set; }
    public string email { get; set; }
    public string picture { get; set; }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: insert data to access database c# 
Csharp :: why to make private fields readonly in c# 
Csharp :: delete items in c# 
Csharp :: c# template strings 
Csharp :: list c# 
Csharp :: dbset 
Csharp :: c# exception middleware 
Csharp :: datetime show 24 hour format c# 
Csharp :: ado stands for 
Csharp :: How to create a class and objects in C# 
Csharp :: assert throw 
Csharp :: unity set cursor position 
Csharp :: how to use var in c# 
Csharp :: google mobile ads app id 
Csharp :: ioptions mock c# unittest 
Csharp :: How do I call a string inside a different class 
Csharp :: system.componentmodel.dataannotations hide field 
Csharp :: dynamics 365 create record c# 
Csharp :: list findall c# 
Csharp :: Null check operator used on a null value 
Csharp :: VSIX Project Context Menu 
Csharp :: c# datagridview select row index programmatically 
Csharp :: how to add extra window to wpf 
Csharp :: ef core index attribute 
Csharp :: c# bitwise and 
Csharp :: you have the following c# code. sb is a a very long string. you need to identify whether a string stored in an object named stringtofind is within the stringbuilder sb object. which code should you use? 
Csharp :: how to reference a local file c# 
Csharp :: how to make a c# encrypt and decrypt string cmd 
Csharp :: flutter find a widget 
Csharp :: how to remove something in c# 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =