• seth dorris 7
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
So I have created a custom REST API that I have tested and validated in workbench.. 

I have successfully parsed the OAuth Access Token from the URL in order to set headers to make an HTTP Call to my custom REST API.

Why then.. am I still getting a 401 Unauthorized Access error when making the HTTP request?

Here is my http request (using angular's http service)
 
$http({
        	method: "GET",
        	url: "https://na30.salesforce.com/services/apexrest/activities",
        	headers: {
            	"Authorization": "Bearer " + token
        	}
    	}).then(function (data) {
        	console.log("data", data)
    	})

 
Has anyone implemented the OAuth sequence on the client side ? Ie. calling a js function that redirects to the request token end point?
If I want to populate my DOM with an initial list of data coming from a custom apex REST API, how do I initiate the OAuth process to get that data?

Is the solution as simple as creating a landing page with a "login" button that fires a call to get a request token?  Once authenticated I redirect to my main page where I have angular populate my DOM with the data I got back from my REST API call once on the main page?
public class activitiesController {

    public List<ABQ_Activity__c> getAllActivities() 
    {
        List<ABQ_Activity__c> activities = Database.Query('SELECT Id FROM ABQ_Activity__c');
        return activities;
    }
}
I do a test.. where I expect the number of activities to be 11 and compare to activities.size(); and I get NOTHING.. I'm getting super pissed and need help.
 
public class activitiesController {

    public List<ABQ_Activity__c> getAllActivities() 
    {
        List<ABQ_Activity__c> activities = Database.Query('SELECT Id FROM ABQ_Activity__c');
        return activities;
    }
}
I do a test.. where I expect the number of activities to be 11 and compare to activities.size(); and I get NOTHING.. I'm getting super pissed and need help.