Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7692657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:54:12+00:00 2026-05-31T20:54:12+00:00

I am able to get access_token for multiple permissions like emails, contacts, docs, etc.

  • 0

I am able to get access_token for multiple permissions like emails, contacts, docs, etc. using oAuth 2.0. I have access_token
I got contacts using the following code.

$url = 'https://www.google.com/m8/feeds/contacts/default/full?max-  results='.$max_results.'&oauth_token='.$access_token;

$response_contacts=  curl_get_file_contents($url);

Now i want to get users Emails using this access_token.
i used this url . but it gives 401 unauthorized Error

$url = 'https://mail.google.com/mail/feed/atom&oauth_token='.$access_token;
$response_emails=  curl_get_file_contents($url);

please guide me how can i get emails using access_token.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:54:13+00:00Added an answer on May 31, 2026 at 8:54 pm

    I’ve seen references to the Gmail feed using oauth_token as a request parameter. However, once I used the OAuth Playground I discovered that you need to pass your OAuth information as an Authorization header, as you’ll see below.

    <?php
    $now = time();
    $consumer = ...; // your own value here
    $secret = ...; // your own value here
    $nonce = ...; // same value you've been using
    $algo = "sha1";
    $sigmeth = "HMAC-SHA1";
    $av = "1.0";
    $scope = "https://mail.google.com/mail/feed/atom";
    $path = $scope;
    $auth = ...; // an object containing outputs of OAuthGetAccessToken
    
    $args = "oauth_consumer_key=" . urlencode($consumer) .
      "&oauth_nonce=" . urlencode($nonce) .
      "&oauth_signature_method=" . urlencode($sigmeth) .
      "&oauth_timestamp=" . urlencode($now) .
      "&oauth_token=" . urlencode($auth->oauth_token) .
      "&oauth_version=" . urlencode($av);
    
    $base = "GET&" . urlencode($path) . "&" . urlencode($args);
    
    $sig = base64_encode(hash_hmac($algo, $base,
      "{$secret}&{$auth->oauth_token_secret}", true));
    
    $url = $path . "?oauth_signature=" . urlencode($sig) . "&" . $args;
    
    // Create a stream
    $opts = array(
      "http" => array(
        "method" => "GET",
        "header" => "Authorization: OAuth " .
           "oauth_version=\"{$av}\", " .
           "oauth_nonce=\"{$nonce}\", " .
           "oauth_timestamp=\"{$now}\", " .
           "oauth_consumer_key=\"{$consumer}\", " .
           "oauth_token=\"{$auth->oauth_token}\", " .
           "oauth_signature_method=\"{$sigmeth}\", " .
           "oauth_signature=\"{$sig}\"\r\n"
      )
    );
    
    $context = stream_context_create($opts);
    
    $out = file_get_contents($path, false, $context);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been able to successfully get an access token from Vimeo using the
here is what i have been able to accomplish: 1.) redirect to get permissions
I am using facebook graph. I am able to retrieve the access_token. Now I
I am using the Server Side flow to get a user's permissions to access
I've successfully managed to get an OAuth access token and am able to make
Possible Duplicate: Parse NSURL query property I have a url like this: someapp://#access_token=1234%D&refresh_token=54%D%D321&instance_url=https%3A%2F%2Fsf.com I
Has anyone been able to get the OAuth access token for a user after
I am able to get the access_token for the salesforce oath2. access token can
I am using this code to get the userInfo twitter = oauthtwitter.OAuthApi(CONSUMER_KEY, CONSUMER_SECRET, access_token)
I need to be able get a single specific attribute from an element with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.